Documentation ¶
Index ¶
- Constants
- func AwaitAlive(ctx context.Context, c Client, freq time.Duration, tags []string, ...) (bool, error)
- func AwaitHealthy(ctx context.Context, c Client, freq time.Duration, tags []string, ...) (bool, error)
- func AwaitReady(ctx context.Context, c Client, freq time.Duration, tags []string, ...) (bool, error)
- func NewGetAndPostHandler(log logging.Logger, reporter Reporter) (http.Handler, error)
- func NewGetHandler(reporter func(tags ...string) (map[string]Result, bool)) http.Handler
- type APIArgs
- type APIReply
- type Checker
- type CheckerFunc
- type Client
- type Health
- type Registerer
- type Reporter
- type Result
- type Service
Constants ¶
const ( // AllTag is automatically added to every registered check. AllTag = "all" // ApplicationTag checks will act as if they specified every tag that has // been registered. // Registering a health check with this tag will ensure that it is always // included in all health query results. ApplicationTag = "application" )
Variables ¶
This section is empty.
Functions ¶
func AwaitAlive ¶
func AwaitAlive(ctx context.Context, c Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
AwaitAlive polls the node every [freq] until the node reports liveness. Only returns an error if [ctx] returns an error.
func AwaitHealthy ¶
func AwaitHealthy(ctx context.Context, c Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
AwaitHealthy polls the node every [freq] until the node reports healthy. Only returns an error if [ctx] returns an error.
func AwaitReady ¶
func AwaitReady(ctx context.Context, c Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
AwaitReady polls the node every [freq] until the node reports ready. Only returns an error if [ctx] returns an error.
func NewGetAndPostHandler ¶
NewGetAndPostHandler returns a health handler that supports GET and jsonrpc POST requests.
Types ¶
type APIArgs ¶
type APIArgs struct {
Tags []string `json:"tags"`
}
APIArgs is the arguments for Readiness, Health, and Liveness.
type Checker ¶
type Checker interface { // HealthCheck returns health check results and, if not healthy, a non-nil // error // // It is expected that the results are json marshallable. HealthCheck(context.Context) (interface{}, error) }
Checker can have its health checked
type CheckerFunc ¶
func (CheckerFunc) HealthCheck ¶
func (f CheckerFunc) HealthCheck(ctx context.Context) (interface{}, error)
type Client ¶
type Client interface { // Readiness returns if the node has finished initialization Readiness(ctx context.Context, tags []string, options ...rpc.Option) (*APIReply, error) // Health returns a summation of the health of the node Health(ctx context.Context, tags []string, options ...rpc.Option) (*APIReply, error) // Liveness returns if the node is in need of a restart Liveness(ctx context.Context, tags []string, options ...rpc.Option) (*APIReply, error) }
Client interface for Avalanche Health API Endpoint For helpers to wait for Readiness, Health, or Liveness, see AwaitReady, AwaitHealthy, and AwaitAlive.
type Health ¶
type Health interface { Registerer Reporter // Start running periodic health checks at the specified frequency. // Repeated calls to Start will be no-ops. Start(ctx context.Context, freq time.Duration) // Stop running periodic health checks. Stop should only be called after // Start. Once Stop returns, no more health checks will be executed. Stop() }
Health defines the full health service interface for registering, reporting and refreshing health checks.
func New ¶
func New(log logging.Logger, registerer prometheus.Registerer) (Health, error)
type Registerer ¶
type Registerer interface { RegisterReadinessCheck(name string, checker Checker, tags ...string) error RegisterHealthCheck(name string, checker Checker, tags ...string) error RegisterLivenessCheck(name string, checker Checker, tags ...string) error }
Registerer defines how to register new components to check the health of.
type Reporter ¶
type Reporter interface { Readiness(tags ...string) (map[string]Result, bool) Health(tags ...string) (map[string]Result, bool) Liveness(tags ...string) (map[string]Result, bool) }
Reporter returns the current health status.
type Result ¶
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"` }