health

package
v3.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHandler = NewHandler()

DefaultHandler is the default health http handler.

View Source
var DefaultPattern = "/health"

DefaultPattern is the default health http path.

Functions

func StartServer

func StartServer(addr string, reporters ...Reporter) error

StartServer starts the http health server on the given port with the given reporters.

func StopServer

func StopServer() error

StopServer stops the htt[ health server

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is an http health handler.

func NewHandler

func NewHandler() *Handler

NewHandler creates a new Handler instance.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an http request.

func (*Handler) With

func (h *Handler) With(reporters ...Reporter) *Handler

With adds reports to the handler.

func (*Handler) WithErrors

func (h *Handler) WithErrors() *Handler

WithErrors configures the handler to show the error message in the response.

type Reporter

type Reporter interface {
	// IsHealthy emits error if application is not healthy.
	IsHealthy() error
}

Reporter represents an a health reporter.

type ReporterFunc

type ReporterFunc func() error

ReporterFunc is an adapter for anonymous functions to be used as health reporters.

func Null added in v3.24.0

func Null() ReporterFunc

Null is the null Health reporter.

func (ReporterFunc) IsHealthy

func (f ReporterFunc) IsHealthy() error

IsHealthy emits error if application is not healthy.

Jump to

Keyboard shortcuts

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