Documentation
¶
Overview ¶
Package httpprobe exposes probes over HTTP with sensible defaults for Kubernetes liveness/readiness/startup checks, but generic enough for any service. It supports two modes:
- Pull: Handler runs the probe synchronously per request (default).
- Cached: CachedHandler reads a state.State updated by a runner.Runner out-of-band — required for expensive checks, gRPC parity, or when many concurrent requests would otherwise stampede the probe.
Index ¶
Constants ¶
const ( DefaultLivenessPath = "/healthz/liveness" DefaultReadinessPath = "/healthz/readiness" DefaultStartupPath = "/healthz/startup" )
Conventional Kubernetes paths.
const DefaultTimeout = 30 * time.Second
DefaultTimeout caps each probe check served via Handler.
Variables ¶
This section is empty.
Functions ¶
func CachedHandler ¶
func CachedHandler(s *state.State, opts ...Option) http.HandlerFunc
CachedHandler returns an http.HandlerFunc that reads from a state.State without invoking any probe. Pair with a runner.Runner that periodically updates the state. Response codes match the pull-mode Handler.
Status is read instantly — no timeout applies. If the state has never been updated (StatusUnknown), the response is 503.
func Handler ¶
func Handler(p probe.Probe, opts ...Option) http.HandlerFunc
Handler returns an http.HandlerFunc that runs the probe and renders the result. Status -> HTTP code: Up=200, Timeout=504, others=503.
Types ¶
type HTTPProbe ¶
HTTPProbe binds a Handler to a path and method.
func NewHTTPProbe ¶
NewHTTPProbe constructs an HTTPProbe served under method GET at path.