Documentation ¶
Overview ¶
Package shutdown provides a graceful shutdown mechanism.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GracefulShutdown ¶
func GracefulShutdown(ctx context.Context, opts ...OptionFunc)
GracefulShutdown gracefully shutdown the server. 1. tell the load balancer this node is offline, and stop sending new requests 2. set the healthcheck status to unhealthy 3. stop accepting new HTTP requests and wait for existing HTTP requests to finish 4. stop accepting new connections and RPCs and blocks until all the pending RPCs are finished. 5. flushing any buffered log entries
Types ¶
type OptionFunc ¶
OptionFunc is a function that can be used to configure a graceful shutdown.
func GRPCServerShutdown ¶
func GRPCServerShutdown(s *grpc.Server) OptionFunc
GRPCServerShutdown shutdown the gRPC server.
func HTTPServerShutdown ¶
func HTTPServerShutdown(httpServer *http.Server) OptionFunc
HTTPServerShutdown shutdown the HTTP server.
func HealthServerShutdown ¶
func HealthServerShutdown(healthServer *health.Server) OptionFunc
HealthServerShutdown shutdown the healthcheck server.
func ResolverDeregister ¶
func ResolverDeregister(pairs ...*resolver.Pair) OptionFunc
ResolverDeregister deregister the service from the resolver.