MCPcopy
hub / github.com/grafana/dskit / WithManager

Function WithManager

grpcutil/health_check.go:18–32  ·  view source on GitHub ↗

WithManager returns a new Check that tests if the managed services are healthy.

(manager *services.Manager)

Source from the content-addressed store, hash-verified

16
17// WithManager returns a new Check that tests if the managed services are healthy.
18func WithManager(manager *services.Manager) Check {
19 return func(context.Context) bool {
20 states := manager.ServicesByState()
21
22 // Given this is a health check endpoint for the whole instance, we should consider
23 // it healthy after all services have been started (running) and until all
24 // services are terminated. Some services, like ingesters, are still
25 // fully functioning while stopping.
26 if len(states[services.New]) > 0 || len(states[services.Starting]) > 0 || len(states[services.Failed]) > 0 {
27 return false
28 }
29
30 return len(states[services.Running]) > 0 || len(states[services.Stopping]) > 0
31 }
32}
33
34// WithShutdownRequested returns a new Check that returns false when shutting down.
35func WithShutdownRequested(requested *atomic.Bool) Check {

Callers 3

NewHealthCheckFunction · 0.85

Calls 1

ServicesByStateMethod · 0.80