Documentation
¶
Overview ¶
Package health provides readiness state tracking and HTTP health check handlers.
Index ¶
Constants ¶
const ( // DefaultPoolWait is how long one probe waits for a connection. It is // under the one second a readiness probe is given by default. DefaultPoolWait = 500 * time.Millisecond // DefaultPoolStarvedFor is how long the pool must go without handing one // out before the replica reports not ready, so a busy pool that frees a // connection now and then is not taken out of service. DefaultPoolStarvedFor = 30 * time.Second )
Pool starvation (#2169). A replica whose database pool hands out no connection serves nothing that reads the database, yet the process state alone kept /readyz at 200 while one did. A pool every connection of which is in use, and stays so, takes the replica out of service. A database that is down is not this: its pool opens no connections, and /readyz leaves an upstream outage to the dependency probes so it never takes every replica out at once.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker tracks the readiness state of the platform. It is safe for concurrent use.
func (*Checker) LivenessHandler ¶
func (*Checker) LivenessHandler() http.HandlerFunc
LivenessHandler returns an http.HandlerFunc that always responds 200 OK. Use this for K8s livenessProbe (/healthz).
func (*Checker) ReadinessHandler ¶
func (c *Checker) ReadinessHandler() http.HandlerFunc
ReadinessHandler returns an http.HandlerFunc that responds 200 when ready and 503 when starting, draining, or its database pool is starved. Use this for K8s readinessProbe (/readyz).
func (*Checker) SetDraining ¶
func (c *Checker) SetDraining()
SetDraining transitions to the Draining state.
type PoolProbe ¶ added in v1.149.0
type PoolProbe struct {
// contains filtered or unexported fields
}
PoolProbe reports whether a database pool can hand out a connection.
func NewPoolProbe ¶ added in v1.149.0
NewPoolProbe probes db, waiting wait for a connection and reporting it starved once it has handed none out for starvedFor.