go.bigb.es/auxilia
Documentation
Index
Functions
func Handlers(mgr *steward.Manager, opts ...Option) (livez, readyz http.Handler)
Handlers returns the liveness and readiness HTTP handlers.
livez always returns 200 with body "ok".
readyz wraps the request context with the configured timeout (default 5s) and calls mgr.HealthCheck. On success it returns 200 with {"status":"ok"}. On failure it returns 503 with {"status":"unready","error":"<message>"} and logs at Warn. Use WithReadyResponse to change the body shape.
Handlers panics if mgr is nil.
Types
type Option func(*config)
Option configures the handlers returned by Handlers.
func WithLogger(l *slog.Logger) Option
WithLogger sets the logger used to report readiness failures. nil means slog.Default(). Failures are logged at Warn so they appear in normal production output without spamming Info.
func WithReadyResponse(fn func(err error) (status int, body any)) Option
WithReadyResponse customises the readiness response shape. The function receives the error returned by Manager.HealthCheck (nil on success) and returns the HTTP status and body to send.
On success the default fn returns (200, {"status":"ok"}). On failure it returns (503, {"status":"unready","error":"<message>"}). The body is JSON-encoded by the handler unless it is a string, in which case it is written as text/plain.
func WithTimeout(d time.Duration) Option
WithTimeout overrides the default 5s readiness timeout.
Package healthhttp exposes /healthz and /readyz handlers backed by a steward Manager.
livez always returns 200 — a process that can answer is alive by definition; coupling liveness to dependencies gets pods killed during transient outages. readyz runs Manager.HealthCheck under a configurable timeout and returns 503 with a JSON body on failure.