health

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = Settings{
	InitialDelay: time.Second,
	Period:       5 * time.Second,
	Timeout:      500 * time.Millisecond,
}

DefaultSettings provides some default health check settings.

Functions

func Run

func Run(ctx context.Context, settings *Settings, state *State, check Check) error

Run the health check publishing the results to state.

Run aborts when context is canceled.

Types

type Check

type Check func(ctx context.Context) error

Check runs the health check under given context.

Healthcheck is considered successful when func returns no error. Func should terminate when context is canceled.

type Settings

type Settings struct {
	InitialDelay time.Duration
	Period       time.Duration
	Timeout      time.Duration
}

Settings configures health check

Fields are similar to k8s pod probe definitions.

type State

type State struct {
	sync.Mutex
	// contains filtered or unexported fields
}

State provides proper locking around health state.

func (*State) AsProto

func (state *State) AsProto() *machineapi.ServiceHealth

AsProto returns protobuf-ready health state.

func (*State) Get

func (state *State) Get() Status

Get returns health status (locked).

func (*State) Init

func (state *State) Init()

Init health status (locked).

func (*State) Subscribe

func (state *State) Subscribe(ch chan<- StateChange)

Subscribe for the notifications on state changes.

func (*State) Unsubscribe

func (state *State) Unsubscribe(ch chan<- StateChange)

Unsubscribe from state changes.

func (*State) Update

func (state *State) Update(healthy bool, message string)

Update health status (locked).

type StateChange

type StateChange struct {
	Old Status
	New Status
}

StateChange is used to notify about status changes.

type Status

type Status struct {
	Healthy     *bool
	LastChange  time.Time
	LastMessage string
}

Status of the healthcheck.

func (*Status) AsProto

func (status *Status) AsProto() *machineapi.ServiceHealth

AsProto returns protobuf-ready health state.

Jump to

Keyboard shortcuts

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