healthchecker

package
v0.0.0-...-e0aa601 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(check Check) http.Handler

Handler turns a Check function into an http.Handler for the GET method at path "/health".

The status code of the healthcheck is determined by the return value of the given check function: - 500 if check is nil - 500 if check returns a non-nil error - 200 otherwise

func Run

func Run(check Check, opts *Options) (shutdown func() error)

Run starts a new HTTP server that listens on opts.ListenAddr (default :5678) and responds to GET /health using the http.Handler returned by Handler(check).

Run will terminate the program if there is any error starting up the HTTP server. Run returns a callback that can be used to shutdown the HTTP server.

Types

type Check

type Check func() error

Check is the type of the healthcheck function accepted by Run

func WrapRPC

func WrapRPC(check func(_ context.Context, _ *empty.Empty, res *health.HealthResponse) error) Check

Wrap transforms a RPC healthcheck into a Check

type Options

type Options struct {
	// If set, this will be used as the listen address for the HTTP server. Defaults to :5678 otherwise
	ListenAddr string
}

Options defines the options for the healthchecker

Jump to

Keyboard shortcuts

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