Documentation
¶
Overview ¶
Package healthz provides tools for service health checks
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHealthCheckFailed = errors.New("Health check failed")
ErrHealthCheckFailed is a generic error returned when a check fails
Functions ¶
This section is empty.
Types ¶
type DbHealthChecker ¶ added in v0.2.0
type DbHealthChecker struct {
// contains filtered or unexported fields
}
DbHealthChecker checks if a database is available through builtin database/sql
func NewDbHealthChecker ¶ added in v0.2.0
func NewDbHealthChecker(db *sql.DB) *DbHealthChecker
NewDbHealthChecker creates a new DB health checker with a connection
func (*DbHealthChecker) Ping ¶ added in v0.2.0
func (c *DbHealthChecker) Ping() error
Ping checks the database status by pinging it
func (*DbHealthChecker) Type ¶ added in v0.2.0
func (c *DbHealthChecker) Type() string
Type returns the name of the database checker
type HTTPHealthChecker ¶ added in v0.2.0
type HTTPHealthChecker struct {
// contains filtered or unexported fields
}
HTTPHealthChecker checks if an HTTP service is available
func NewHTTPHealthChecker ¶ added in v0.2.0
func NewHTTPHealthChecker(url string) *HTTPHealthChecker
NewHTTPHealthChecker creates a new HTTP health checker with an URL
func (*HTTPHealthChecker) Ping ¶ added in v0.2.0
func (c *HTTPHealthChecker) Ping() error
Ping checks the database status by pinging it
func (*HTTPHealthChecker) Type ¶ added in v0.2.0
func (c *HTTPHealthChecker) Type() string
Type returns the name of the database checker
type HealthChecker ¶
HealthChecker is responsible for checking certain resources
type HealthService ¶
HealthService is the HTTP handler implementation which wraps the Probe and Checker logic
func NewHealthService ¶
func NewHealthService(livenessProbe *Probe, readinessProbe *Probe) *HealthService
NewHealthService creates a new HealthService from user configured Probes
func (*HealthService) HealthStatus ¶
func (s *HealthService) HealthStatus(w http.ResponseWriter, r *http.Request)
HealthStatus checks if the application is healthy
func (*HealthService) ReadinessStatus ¶
func (s *HealthService) ReadinessStatus(w http.ResponseWriter, r *http.Request)
ReadinessStatus checks if the app is ready for accepting request (eg. database is available as well)
func (*HealthService) RegisterHandlers ¶ added in v0.3.0
func (s *HealthService) RegisterHandlers(mux *http.ServeMux)
RegisterHandlers registers HTTP Endpoints in a Mux
type Probe ¶
type Probe struct {
// contains filtered or unexported fields
}
Probe is responsible for executing a series of checks and decide if the service is up or not
func NewProbe ¶
func NewProbe(checkers ...HealthChecker) *Probe
NewProbe is a shortcut for easily creating a new Probe
type StatusHealthChecker ¶
type StatusHealthChecker struct {
// contains filtered or unexported fields
}
StatusHealthChecker checks the status based on an internal state
func NewStatusHealthChecker ¶ added in v0.2.0
func NewStatusHealthChecker(status bool) *StatusHealthChecker
NewStatusHealthChecker creates a new status health checker with an initial status
func (*StatusHealthChecker) Ping ¶
func (c *StatusHealthChecker) Ping() error
Ping checks the internal status and returns an error if it is false
func (*StatusHealthChecker) SetStatus ¶ added in v0.2.0
func (c *StatusHealthChecker) SetStatus(status bool)
SetStatus sets the internal status
func (*StatusHealthChecker) Type ¶
func (c *StatusHealthChecker) Type() string
Type returns the name of the status checker