WithManager returns a new Check that tests if the managed services are healthy.
(manager *services.Manager)
| 16 | |
| 17 | // WithManager returns a new Check that tests if the managed services are healthy. |
| 18 | func 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. |
| 35 | func WithShutdownRequested(requested *atomic.Bool) Check { |