health

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

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

This section is empty.

Types

type Check

type Check interface {
	// Name is the identifier for this check and must be unique among all Checks
	Name() string

	// Execute performs the health check. It returns nil if the check passes.
	// It can also return additional information to marshal and display to the caller
	Execute() (interface{}, error)

	// ExecutionPeriod is the duration to wait between executions of this Check
	ExecutionPeriod() time.Duration

	// InitialDelay is the duration to wait before executing the first time
	InitialDelay() time.Duration

	// InitiallyPassing is whether or not to consider the Check healthy before the
	// initial execution
	InitiallyPassing() bool
}

Check defines a single health check that we want to monitor and consider as part of our wider healthiness

type CheckFn

type CheckFn func() (interface{}, error)

CheckFn returns optional status information and an error indicating health or non-health

func HeartbeatCheckFn

func HeartbeatCheckFn(hb Heartbeater, max time.Duration) CheckFn

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

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 Check) error

RegisterCheck adds the given Check

func (*Health) RegisterCheckFunc

func (h *Health) RegisterCheckFunc(name string, checkFn CheckFn) error

RegisterCheckFunc adds a Check with default options and the given CheckFn

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 added in v0.6.1

func (h *Health) RegisterMonotonicCheckFunc(name string, checkFn CheckFn) 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