health

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetAndPostHandler added in v0.5.1

func NewGetAndPostHandler(log logging.Logger, reporter Reporter) (http.Handler, error)

NewGetAndPostHandler returns a health handler that supports GET and jsonrpc POST requests.

func NewGetHandler added in v0.5.1

func NewGetHandler(reporter func() (map[string]Result, bool)) http.Handler

NewGetHandler return a health handler that supports GET requests reporting the result of the provided [reporter].

Types

type APIHealthReply

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

APIHealthReply is the response for Health

type Checker added in v0.5.1

type Checker interface {
	// HealthCheck returns health check results and, if not healthy, a non-nil
	// error
	HealthCheck() (interface{}, error)
}

Checker can have its health checked

type CheckerFunc added in v0.5.1

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

func (CheckerFunc) HealthCheck added in v0.5.1

func (f CheckerFunc) HealthCheck() (interface{}, error)

type Client

type Client interface {
	// Readiness returns if the node has finished initialization
	Readiness(context.Context) (*APIHealthReply, error)
	// Health returns a summation of the health of the node
	Health(context.Context) (*APIHealthReply, error)
	// Liveness returns if the node is in need of a restart
	Liveness(context.Context) (*APIHealthReply, error)
	// AwaitHealthy queries the Health endpoint with a pause of [interval]
	// in between checks and returns early if Health returns healthy
	AwaitHealthy(ctx context.Context, freq time.Duration) (bool, error)
}

Client interface for Avalanche Health API Endpoint

func NewClient

func NewClient(uri string) Client

NewClient returns a client to interact with Health API endpoint

type Health added in v0.4.0

type Health interface {
	Registerer
	Reporter

	Start(freq time.Duration)
	Stop()
}

Health defines the full health service interface for registering, reporting and refreshing health checks.

func New added in v0.4.0

func New(registerer prometheus.Registerer) (Health, error)

type Registerer added in v0.5.1

type Registerer interface {
	RegisterReadinessCheck(name string, checker Checker) error
	RegisterHealthCheck(name string, checker Checker) error
	RegisterLivenessCheck(name string, checker Checker) error
}

Registerer defines how to register new components to check the health of.

type Reporter added in v0.5.1

type Reporter interface {
	Readiness() (map[string]Result, bool)
	Health() (map[string]Result, bool)
	Liveness() (map[string]Result, bool)
}

Reporter returns the current health status.

type Result added in v0.2.3

type Result struct {
	// Details of the HealthCheck.
	Details interface{} `json:"message,omitempty"`

	// Error is the string representation of the error returned by the failing
	// HealthCheck. The value is nil if the check passed.
	Error *string `json:"error,omitempty"`

	// Timestamp of the last HealthCheck.
	Timestamp time.Time `json:"timestamp,omitempty"`

	// Duration is the amount of time this HealthCheck last took to evaluate.
	Duration time.Duration `json:"duration"`

	// ContiguousFailures the HealthCheck has returned.
	ContiguousFailures int64 `json:"contiguousFailures,omitempty"`

	// TimeOfFirstFailure of the HealthCheck,
	TimeOfFirstFailure *time.Time `json:"timeOfFirstFailure,omitempty"`
}

type Service

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

func (*Service) Health added in v0.4.0

func (s *Service) Health(_ *http.Request, _ *struct{}, reply *APIHealthReply) error

Health returns a summation of the health of the node

func (*Service) Liveness added in v0.5.1

func (s *Service) Liveness(_ *http.Request, _ *struct{}, reply *APIHealthReply) error

Liveness returns if the node is in need of a restart

func (*Service) Readiness added in v0.5.1

func (s *Service) Readiness(_ *http.Request, _ *struct{}, reply *APIHealthReply) error

Readiness returns if the node has finished initialization

Jump to

Keyboard shortcuts

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