Skip to main content

internal/api/health.go

internal/api · 68 lines · 5 declarations · source

Declarations

type Readiness

type Readiness struct {
mu sync.Mutex
check func(context.Context) error
checking bool
checkedAt time.Time
ready bool
}

Readiness permits one dependency check at a time and caches either result for one second. Probe clients cannot amplify pool acquisition or cancel a shared check to poison its result.

source

func NewReadiness

func NewReadiness(check func(context.Context) error) *Readiness

source

method Readiness.ServeHTTP

func (h *Readiness) ServeHTTP(w http.ResponseWriter, r *http.Request)

source

func HealthHandler

func HealthHandler(ready http.Handler) http.Handler

HealthHandler exposes only liveness/readiness for a worker's loopback listener.

source

func registerHealth

func registerHealth(mux *http.ServeMux, ready http.Handler)

source