Microservices are designed to run on cloud hardware that often shuts down at unpredictable times. When a microservice receives the signal to terminate, it first stops accepting new operations and attempts to end all pending operations gracefully.
Graceful shutdown process:
context.Context
of the microserviceIn order for goroutines to gracefully shut down, it is important to launch them using the Connector
’s Go
method rather than using the standard go
keyword. When launched with Go
, the goroutines are given the context.Context
that gets canceled during termination.