2026-05-29 15:48:11 +00:00
|
|
|
// Package health provides a concurrent health check HTTP handler.
|
|
|
|
|
//
|
|
|
|
|
// The handler runs all registered checks in parallel, collects results within
|
|
|
|
|
// a configurable timeout, and returns a structured JSON response. It maps
|
|
|
|
|
// directly onto Kubernetes liveness and readiness probes.
|
|
|
|
|
//
|
|
|
|
|
// Components register themselves by implementing
|
|
|
|
|
// [observability.Checkable] from einherjar/contracts — no adapter needed.
|
|
|
|
|
//
|
|
|
|
|
// - [observability.LevelCritical]: if DOWN, overall status is DOWN (503)
|
|
|
|
|
// - [observability.LevelDegraded]: if DOWN, overall status is DEGRADED (200)
|
|
|
|
|
//
|
|
|
|
|
// # Example
|
|
|
|
|
//
|
2026-08-07 19:07:57 -06:00
|
|
|
// srv.Get("/health", health.NewHandler(logger, db, cache, storage).ServeHTTP)
|
2026-05-29 15:48:11 +00:00
|
|
|
//
|
|
|
|
|
// Or with custom timeout:
|
|
|
|
|
//
|
|
|
|
|
// srv.Get("/health", health.NewHandlerWithConfig(logger,
|
|
|
|
|
// health.Config{CheckTimeout: 3 * time.Second},
|
|
|
|
|
// db, cache,
|
2026-08-07 19:07:57 -06:00
|
|
|
// ).ServeHTTP)
|
2026-05-29 15:48:11 +00:00
|
|
|
package health
|