Documentation ¶
Index ¶
Constants ¶
View Source
const ( // LivenessURI is the endpoint URI used for liveness check. LivenessURI = "/healthz" // ReadinessURI is the endpoint URI used for readiness check. ReadinessURI = "/readyz" // StatusCodeHealthy is the status code which indicates a healthy state. StatusCodeHealthy = http.StatusOK // StatusCodeNotHealthy is the status code which indicates a not healthy state. StatusCodeNotHealthy = http.StatusInternalServerError )
Variables ¶
This section is empty.
Functions ¶
func DefaultCheck ¶
func DefaultCheck(w http.ResponseWriter, _ *http.Request)
DefaultCheck always writes a 2XX status code for the given http.ResponseWriter.
Types ¶
type Checker ¶
type Checker interface { ReadinessCheck(w http.ResponseWriter, r *http.Request) LivenessCheck(w http.ResponseWriter, r *http.Request) }
type CheckerOpt ¶
type CheckerOpt func(*ConfigurableChecker)
CheckerOpt represents a health checker option.
func WithLivenessCheck ¶
func WithLivenessCheck(h http.HandlerFunc) CheckerOpt
WithLivenessCheck returns CheckerOpt which sets the liveness check for the given http.HandlerFunc. It panics if the given http.HandlerFunc is nil.
func WithReadinessCheck ¶
func WithReadinessCheck(h http.HandlerFunc) CheckerOpt
WithReadinessCheck returns CheckerOpt which sets the readiness check for the given http.HandlerFunc. It panics if the given http.HandlerFunc is nil.
type ConfigurableChecker ¶
type ConfigurableChecker struct {
// contains filtered or unexported fields
}
ConfigurableChecker represents a health checker.
func NewChecker ¶
func NewChecker(opts ...CheckerOpt) *ConfigurableChecker
NewChecker returns a new instance of ConfigurableChecker initialized with the default liveness and readiness checks.
func (ConfigurableChecker) LivenessCheck ¶
func (c ConfigurableChecker) LivenessCheck(w http.ResponseWriter, r *http.Request)
func (ConfigurableChecker) ReadinessCheck ¶
func (c ConfigurableChecker) ReadinessCheck(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.