health

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: BSD-3-Clause Imports: 10 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHeartbeatNotDetected is returned from a HeartbeatCheckFn when the
	// heartbeat has not been detected recently enough
	ErrHeartbeatNotDetected = errors.New("heartbeat not detected")
)

Functions

func HeartbeatCheckFn

func HeartbeatCheckFn(hb Heartbeater, max time.Duration) func() (interface{}, error)

HeartbeatCheckFn returns a CheckFn that checks the given heartbeater has pulsed within the given duration

func NewCheck added in v1.0.3

func NewCheck(name string, execute func() (interface{}, error)) checks.Check

NewCheck creates a new check with name [name] that calls [execute] to evalute health.

Types

type GetLivenessArgs

type GetLivenessArgs struct{}

GetLivenessArgs are the arguments for GetLiveness

type GetLivenessReply

type GetLivenessReply struct {
	Checks  map[string]health.Result `json:"checks"`
	Healthy bool                     `json:"healthy"`
}

GetLivenessReply is the response for GetLiveness

type Health

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

Health observes a set of vital signs and makes them available through an HTTP API.

func NewService

func NewService(log logging.Logger) *Health

NewService creates a new Health service

func (*Health) GetLiveness

func (h *Health) GetLiveness(_ *http.Request, _ *GetLivenessArgs, reply *GetLivenessReply) error

GetLiveness returns a summation of the health of the node

func (*Health) Handler

func (h *Health) Handler() (*common.HTTPHandler, error)

Handler returns an HTTPHandler providing RPC access to the Health service

func (*Health) RegisterCheck

func (h *Health) RegisterCheck(c checks.Check) error

RegisterCheck adds the given Check

func (*Health) RegisterHeartbeat

func (h *Health) RegisterHeartbeat(name string, hb Heartbeater, max time.Duration) error

RegisterHeartbeat adds a check with default options and a CheckFn that checks the given heartbeater for a recent heartbeat

func (*Health) RegisterMonotonicCheckFunc

func (h *Health) RegisterMonotonicCheckFunc(name string, checkFn func() (interface{}, error)) error

RegisterMonotonicCheckFunc adds a Check with default options and the given CheckFn After it passes once, its logic (checkFunc) is never run again; it just passes

type Heartbeater

type Heartbeater interface {
	GetHeartbeat() int64
}

Heartbeater provides a getter to the most recently observed heartbeat

Jump to

Keyboard shortcuts

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