healthx

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAliveHandler

func AddAliveHandler(r *mux.Router)

AddAliveHandler add the liveness probe handler function into the http server

func AddReadyHandler

func AddReadyHandler(r *mux.Router, c Checker)

AddReadyHandler add the readiness probe handler function into the http server

func Alive

func Alive(w http.ResponseWriter, _ *http.Request)

Alive handles the liveness probe

func Check

func Check(checks []Checkable) (err error)

Check runs all healthy functions from the list

func DefaultHealthyHandler

func DefaultHealthyHandler(w http.ResponseWriter, r *http.Request)

DefaultHealthyHandler is the handler used if no healthy handler present

func DefaultUnhealthyHandler

func DefaultUnhealthyHandler(w http.ResponseWriter, r *http.Request, err error)

DefaultUnhealthyHandler is the handler used if no unhealthy handler present

Types

type Checkable

type Checkable interface {
	Healthy() error
}

Checkable should return nil when the thing they are checking is healthy, and an error otherwise.

func NewGoRoutineChecker

func NewGoRoutineChecker(threshold int) Checkable

NewGoRoutineChecker returns a new threshold go routine Checker instance

type Checker

type Checker struct {
	// Checks are the Checkable 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"`
}

StatusResponse payloads to respect for check error

type StatusResponseDetails

type StatusResponseDetails struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

StatusResponseDetails details for payload error response

type UnhealthyHandler

type UnhealthyHandler func(w http.ResponseWriter, r *http.Request, err error)

UnhealthyHandler type for unhealthy

Jump to

Keyboard shortcuts

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