health

package
v0.0.0-...-bbd7aa9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 96 modules, 147 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

health

A simple framework for implementing an HTTP health check endpoint on servers.

Users implement their health.Checkable types, and create a health.Checker, from which they can get an http.HandlerFunc using health.Checker.MakeHealthHandlerFunc.

Documentation

For more details, visit the docs on gopkgdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(checks []Checkable) (err error)

func DefaultHealthyHandler

func DefaultHealthyHandler(w http.ResponseWriter, r *http.Request)

func DefaultUnhealthyHandler

func DefaultUnhealthyHandler(w http.ResponseWriter, r *http.Request, err error)

func ExpvarHandler

func ExpvarHandler(w http.ResponseWriter, r *http.Request)

ExpvarHandler is copied from https://golang.org/src/expvar/expvar.go, where it's sadly unexported.

Types

type Checkable

type Checkable interface {
	Healthy() error
}

Checkables should return nil when the thing they are checking is healthy, and an error otherwise.

type Checker

type Checker struct {
	// Checks are the Checkables to be checked when probing.
	Checks []Checkable

	// Unhealthyhandler is called when one or more of the checks are unhealthy.
	// If not provided DefaultUnhealthyHandler is called.
	UnhealthyHandler UnhealthyHandler

	// HealthyHandler is called when all checks are healthy.
	// If not provided, DefaultHealthyHandler is called.
	HealthyHandler http.HandlerFunc
}

Checker provides a way to make an endpoint which can be probed for system health.

func (Checker) ServeHTTP

func (c Checker) ServeHTTP(w http.ResponseWriter, r *http.Request)

type StatusResponse

type StatusResponse struct {
	Status  string                 `json:"status"`
	Details *StatusResponseDetails `json:"details,omitempty"`
}

type StatusResponseDetails

type StatusResponseDetails struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type UnhealthyHandler

type UnhealthyHandler func(w http.ResponseWriter, r *http.Request, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL