health

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(New),
)

Module exported for intialising the health checker.

Functions

This section is empty.

Types

type Check

type Check struct {
	// The Name must be unique among all checks. Name is a required attribute.
	Name string // Required

	// Check is the check function that will be executed to check availability.
	// This function must return an error if the checked service is considered
	// not available. Check is a required attribute.
	Check func(ctx context.Context) error // Required

	// Timeout will override the global timeout value, if it is smaller than
	// the global timeout (see WithTimeout).
	Timeout time.Duration // Optional

	// MaxTimeInError will set a duration for how long a service must be
	// in an error state until it is considered down/unavailable.
	MaxTimeInError time.Duration // Optional

	// MaxContiguousFails will set a maximum number of contiguous
	// check fails until the service is considered down/unavailable.
	MaxContiguousFails uint // Optional

	// StatusListener allows to set a listener that will be called
	// whenever the AvailabilityStatus (e.g. from "up" to "down").
	StatusListener func(ctx context.Context, name string, state health.CheckState) // Optional

	RefreshPeriod time.Duration
	InitialDelay  time.Duration
}

Check represents a single health check.

type Checks

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

Checks holds a list of Check from a list of health.Check.

func New

func New() *Checks

New returns a new list of Check.

func (*Checks) CompileHealthCheckerOption

func (c *Checks) CompileHealthCheckerOption() []health.CheckerOption

CompileHealthCheckerOption takes a list of Check and returns health.CheckerOption.

func (*Checks) RegisterChecks

func (c *Checks) RegisterChecks(checks ...Check)

RegisterChecks registers a list of health.Check.

Jump to

Keyboard shortcuts

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