health

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: BSD-3-Clause Imports: 11 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

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

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 CheckRegisterer

type CheckRegisterer interface {
	RegisterCheck(c checks.Check) error
}

CheckRegisterer is an interface that can register health checks

func NewNoOpService

func NewNoOpService() CheckRegisterer

NewNoOpService returns a NoOp version of health check for when the Health API is disabled

type Client

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

Client for Avalanche Health API Endpoint

func NewClient

func NewClient(uri string, requestTimeout time.Duration) *Client

NewClient returns a client to interact with Health API endpoint

func (*Client) AwaitHealthy

func (c *Client) AwaitHealthy(checks int, interval time.Duration) (bool, error)

AwaitHealthy queries the GetLiveness endpoint checks times, with a pause of [interval] in between checks and returns early if GetLiveness returns healthy

func (*Client) GetLiveness

func (c *Client) GetLiveness() (*GetLivenessReply, error)

GetLiveness returns a health check on the Avalanche node

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