prober

package
v5.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProbeNotFound = errors.New("probe not found")

ErrProbeNotFound is emitted when a check is performed on a probe that was not added to the prober

Functions

func ProberWrapper

func ProberWrapper(ctx context.Context, probe Probe, res chan error)

Types

type Probe

type Probe interface {
	Name() string
	Check(context.Context) error
}

Probe define a minimal set of methods that a probe should implement

type ProbeResult

type ProbeResult struct {
	Name     string        `json:"name"`
	Healthy  bool          `json:"healthy"`
	Comment  string        `json:"comment"`
	Error    error         `json:"error"`
	Duration time.Duration `json:"duration"`
}

ProbeResult is the data structure used to retain the data fetched from a single probe

type Prober

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

Prober entrypoint of the philae api. It will retain a set of probe and run checks when asked to

func NewProber

func NewProber(opts ...ProberOption) *Prober

NewProber is the default constructor of a Prober

func (*Prober) AddProbe

func (p *Prober) AddProbe(probe Probe)

func (*Prober) Check

func (p *Prober) Check(ctx context.Context) *Result

Check will run the check of each probes added and return the result in a Result struct

func (*Prober) CheckOneProbe

func (p *Prober) CheckOneProbe(ctx context.Context, probeName string) *ProbeResult

type ProberError

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

func (*ProberError) AddError

func (e *ProberError) AddError(name string, err error)

func (*ProberError) Error

func (e *ProberError) Error() string

func (*ProberError) IsEmpty

func (e *ProberError) IsEmpty() bool

type ProberOption

type ProberOption func(p *Prober)

ProberOption is a function modifying some parameters of the Prober

func WithTimeout

func WithTimeout(d time.Duration) ProberOption

WithTimeout is a ProberOption which defines a timeout the prober have to get executed into Recommandation: it should be higher than the timeout of the probes included in it, otherwise it would mask the real errors.

type Result

type Result struct {
	Healthy bool           `json:"healthy"`
	Probes  []*ProbeResult `json:"probes"`
	Error   error          `json:"error"`
}

Result is the data structure used to retain the data fetched from a single run of each probes

Jump to

Keyboard shortcuts

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