Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StartedAt = time.Now()
StartedAt is the time the service was started.
var Version string
Version of service, initialized at compiled time.
Functions ¶
func Handler ¶
func Handler(chk Checker) http.HandlerFunc
Handler returns a HTTP handler that serves health check requests. The response body is the health status returned by chk.Check(). By default it's encoded as JSON, but you can specify a different encoding in the HTTP Accept header. The response status is 200 if chk.Check() returns a nil error, 503 otherwise.
Types ¶
type Checker ¶
type Checker interface {
// Check that all dependencies are healthy. Check returns true
// if the service is healthy. The returned Health struct
// contains the health status of each dependency.
Check(context.Context) (*Health, bool)
}
Checker exposes a health check.
func NewChecker ¶
Create a Checker that checks the health of the given dependencies.
type Health ¶
type Health struct {
// Uptime of service in seconds.
Uptime int64 `json:"uptime"`
// Version of service.
Version string `json:"version"`
// Status of each dependency indexed by service name.
// "OK" if dependency is healthy, "NOT OK" otherwise.
Status map[string]string `json:"status,omitempty"`
}
Health status of a service.
func (Health) MarshalXML ¶
type Option ¶
type Option func(o *options)
Option configures a Pinger.
func WithScheme ¶
WithScheme sets the scheme used to ping the service. Default scheme is "http".
func WithTimeout ¶
WithTimeout sets the timeout used to ping the service. Default is no timeout.
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option