health

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = variant.NewRegistry[checker]()

Functions

This section is empty.

Types

type Checker

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

func NewChecker

func NewChecker(c checker) Checker

func (*Checker) UnmarshalYAML

func (t *Checker) UnmarshalYAML(node *yaml.Node) (e error)

type HealthState

type HealthState int8
const (
	Healthy   HealthState = 1
	Unhealthy HealthState = -1
	Unknown   HealthState = 0
)

func (HealthState) String

func (s HealthState) String() string

type HttpCheck

type HttpCheck struct {
	Method          string            `yaml:"method"`           // The HTTP method to use
	Path            string            `yaml:"path"`             // The path to request
	FollowRedirects bool              `yaml:"follow_redirects"` // Follow redirects
	Header          map[string]string `yaml:"header"`           // The headers to send with the request
	Code            int               `yaml:"code"`             // Expected status code
	Body            string            `yaml:"body"`             // Expected body
}

func (*HttpCheck) Perform

func (t *HttpCheck) Perform(ctx context.Context, addr string) error

func (*HttpCheck) UnmarshalInline

func (t *HttpCheck) UnmarshalInline(text string) error

type Monitor

type Monitor struct {
	Healthy   MonitorLoop        `yaml:"healthy"`   // The loop for healthy checks.
	Unhealthy MonitorLoop        `yaml:"unhealthy"` // The loop for unhealthy checks.
	Timeout   util.Duration      `yaml:"timeout"`   // The timeout for each check.
	Checks    map[string]Checker `yaml:"test"`      // The checks to perform.
}

func (*Monitor) Check

func (m *Monitor) Check(ctx context.Context, logger *xlog.Logger, address string) bool

func (*Monitor) Observe

func (m *Monitor) Observe(ctx context.Context, logger *xlog.Logger, address string, observer Observer)

type MonitorLoop

type MonitorLoop struct {
	Interval  util.Duration `yaml:"interval"`
	Threshold int           `yaml:"threshold"`
}

func (MonitorLoop) Or

type Observer

type Observer interface {
	SetHealthy(healthy bool)
}

type ObserverFunc

type ObserverFunc func(healthy bool)

func (ObserverFunc) SetHealthy

func (f ObserverFunc) SetHealthy(healthy bool)

type TcpCheck

type TcpCheck struct{}

func (*TcpCheck) Perform

func (t *TcpCheck) Perform(ctx context.Context, addr string) error

func (*TcpCheck) UnmarshalInline

func (t *TcpCheck) UnmarshalInline(text string) error

Jump to

Keyboard shortcuts

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