health

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckContext added in v1.0.0

func CheckContext(ctx context.Context) context.Context

func IsCheck added in v1.0.0

func IsCheck(ctx context.Context) bool

func WaitForTestDial added in v0.12.2

func WaitForTestDial(ctx context.Context, addr net.Addr)

WaitForTestDial tries to create a client connection to the given target with a blocking dial and a timeout specified in testDialTimeout. Nothing is done with the connection, which is just closed in case it is created.

Types

type Checkable added in v1.0.0

type Checkable interface {
	CheckHealth() State
}

Checkable is the interface implemented by subsystems that the checker uses to determine subsystem health.

type Checker

type Checker interface {
	AddCheck(name string, checkable Checkable) error
}

Checker is responsible for running health checks and serving the healthcheck HTTP paths

type Config

type Config struct {
	ListenerEnabled bool `hcl:"listener_enabled"`

	// Address and port to listen on, defaulting to localhost:80
	BindAddress string `hcl:"bind_address"`
	BindPort    string `hcl:"bind_port"`

	// Paths for /ready and /live
	ReadyPath string `hcl:"ready_path"`
	LivePath  string `hcl:"live_path"`

	UnusedKeyPositions map[string][]token.Pos `hcl:",unusedKeyPositions"`
}

type Details added in v0.12.2

type Details struct {
	Message string `json:"message,omitempty"`
}

Details are additional data to be used when the system is ready

type ServableChecker added in v1.0.0

type ServableChecker interface {
	Checker
	ListenAndServe(ctx context.Context) error
}

func NewChecker

func NewChecker(config Config, log logrus.FieldLogger) ServableChecker

type State added in v1.0.0

type State struct {
	// Live is whether or not the subsystem is live (i.e. in a good state
	// or in a state it can recover from while remaining alive). Global
	// liveness is only reported true if all subsystems report live.
	Live bool

	// Ready is whether or not the subsystem is ready (i.e. ready to perform
	// its function). Global readiness is only reported true if all subsystems
	// report ready.
	Ready bool

	// Subsystems can return whatever details they want here as long as it is
	// serializable via json.Marshal.
	// LiveDetails are opaque details related to the live check.
	LiveDetails any

	// ReadyDetails are opaque details related to the live check.
	ReadyDetails any
}

State is the health state of a subsystem.

Jump to

Keyboard shortcuts

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