Documentation ¶
Overview ¶
This package provides a simple health check server.
The package lets you register arbitrary health check endpoints by providing a name (== URL path) and a callback function.
The health check server listens for HTTP requests on a given port; probes are executed by issuing requests to the endpoints' named URL paths.
GETing the "/" path provides a list of registered endpoints, one per line. GETing "/_ALL_" probes each registered endpoint sequentially, returning each endpoint's path, HTTP status code and body per line.
The package works as a "singleton" with just one server in order to avoid cluttering the main program by passing handles around.
Index ¶
Constants ¶
const ( StatusOK = http.StatusOK )
Variables ¶
This section is empty.
Functions ¶
func AddEndpoint ¶
func AddEndpoint(urlPath string, callback CallbackFunc)
Registers an endpoint with the health checker.
The urlPath must be unique. The callback must return an HTTP response code and body text.
Boilerplate:
healthcheck.AddEndpoint("/my/arbitrary/path" func()(code int, body string) { return 200, "Foobar Plugin is OK" })
func AddEndpointPathArray ¶
func AddEndpointPathArray(urlPath []string, callback CallbackFunc)
Registers an endpoint with the health checker.
This is a convenience version of AddEndpoint() that takes the urlPath's components as a list of strings and catenates them.
func Configure ¶
func Configure(listenAddr string)
Configures the health check server
listenAddr: an address understood by http.ListenAndServe(), e.g. ":8008"
Types ¶
type CallbackFunc ¶
Code wishing to get probed by the health-checker needs to provide this callback