health

package
Version: v0.0.0-...-53c5426 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

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)

Source Files

Jump to

Keyboard shortcuts

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