probe

package
v0.0.0-...-12a582f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMaxFailuresExceeded is returned when the probe is triggered
	ErrMaxFailuresExceeded = errors.New("max failures exceeded")

	// ErrNoProbeTypeSpecified if no probe type/kind is specific in the probe
	// config
	ErrNoProbeTypeSpecified = errors.New("no probe kind specified in probe.Kind")

	// ErrProbeTypeNotAvailable is returned if not probe of type is
	// available to load
	ErrProbeTypeNotAvailable = errors.New("probe kind not available")
)
View Source
var (
	// ErrURLNotDefined is returned if the probe config does not
	// have a url set in the Target field of Config
	ErrURLNotDefined = errors.New("URL not set in Config.Target")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Target string `yaml:"targer" json:"target"`
}

Config is a general config object for probes

type HTTPProbe

type HTTPProbe struct {
	URL string
	// contains filtered or unexported fields
}

HTTPProbe is the HTTP probe

func NewHTTPProbe

func NewHTTPProbe() *HTTPProbe

NewHTTPProbe instantiates a HTTP probe with the default configured http client

func (*HTTPProbe) Check

func (h *HTTPProbe) Check() (bool, error)

Check performs a status check of the probe

type Kind

type Kind int
const (
	// DefaultMaxFailures is the default limit when to trigger the probe
	DefaultMaxFailures = 5

	// DefaultPollInterval is the default interval at which to run the probe
	DefaultPollInterval = time.Second * 5

	// Http uses simple http checks to fulfil probe behavior
	HTTP Kind = iota

	// Listener implements a listener to some type of subscription channel
	// fulfil a passive probe
	Listener

	// Event awaits some trigger/event as a to fulfil a passive probe
	Event

	// Readiness will use the ProbeReadiness check in a provider
	Readiness

	// Liveness will use the ProbeLiveness check in a provider
	Liveness
)

type Probe

type Probe struct {
	Name        string        `yaml:"name" json:"name"`
	Kind        Kind          `yaml:"kind" json:"kind"`
	Interval    time.Duration `yaml:"duration" json:"duration"`
	MaxFailures int           `yaml:"maxFailures" json:"maxFailures"`
	Spec        Config        `yaml:"spec" json:"spec"`

	Performer adapter

	LastStatus bool `yaml:"lastStatus" json:"lastStatus"`
	Checks     int
	Failures   int `yaml:"failures" json:"failures"`
	// contains filtered or unexported fields
}

Probe is a mechanism with which to check for some state, track said state, and trigger itself if a state is observed outside a tolerance

func NewProbe

func NewProbe() *Probe

NewProbe returns an instantiated probe

func (*Probe) Await

func (p *Probe) Await() chan bool

Await allows us to await a completion message from a probe

func (*Probe) Start

func (p *Probe) Start() chan bool

Start begins continuously running a Probe

func (*Probe) Stop

func (p *Probe) Stop() error

Stop stops a running Probe

Jump to

Keyboard shortcuts

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