probe

package
v0.0.0-...-4308112 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package probe provides a common set of interfaces and default implementations to facilitate probe support over many packages in Juju. To implement probes we follow the common language introduced by Kubernetes in this area.

Index

Constants

View Source
const (
	// ProbeLiveness represents a liveness probe
	ProbeLiveness = ProbeType("liveness")

	// ProbeLiveness represents a readiness probe
	ProbeReadiness = ProbeType("readiness")

	// ProbeLiveness represents a startup probe
	ProbeStartup = ProbeType("startup")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate struct {
	// Probes is a map of probes to run as part of this aggregate with the key
	// corresponding to well known name for the probe.
	Probes map[string]Prober
}

Aggregate is an implementation of the Prober interface that returns success if all probes under it's controler are successful or false if one more of the probes fail. Convenience NewAggregate() exists to initialise the map.

func NewAggregate

func NewAggregate() *Aggregate

func (*Aggregate) Probe

func (a *Aggregate) Probe() (bool, error)

Probe implements Prober Probe

func (*Aggregate) ProbeWithResultCallback

func (a *Aggregate) ProbeWithResultCallback(
	cb ProbeResultCallback,
) (bool, error)

ProbeWithResultCallback functions the same as Probe but for each probe tested in the aggregate calls the provided callback with probe name and result. Useful for building more details reports of what probes are failing and succeeding.

type LivenessProber

type LivenessProber interface {
	// LivenessProbe returns the Prober to use for Liveness probes.
	LivenessProbe() Prober
}

LivenessProber is an interface for probing targets that implement liveness probe support.

type ProbeProvider

type ProbeProvider interface {
	SupportedProbes() SupportedProbes
}

ProberProvider is implemented by entities that wish to controbute probes to the overall applications probe support.

func LivenessProvider

func LivenessProvider(probe Prober) ProbeProvider

LivenessProvider is a utility function for returning a ProbeProvider for the provided liveness probe.

func Provider

func Provider(supported SupportedProbes) ProbeProvider

Provider is a utility function for returning a ProbeProvider based on the SupportedProbes passed in.

func ReadinessProvider

func ReadinessProvider(probe Prober) ProbeProvider

ReadinessProvider is a utility function for returning a ProbeProvider for the provided readiness probe.

type ProbeResultCallback

type ProbeResultCallback func(probeKey string, val bool, err error)

ProbeResultCallBack is a function signature for receiving the result of a probers probe call.

type ProbeType

type ProbeType string

ProbeType is an alias type to describe the type of probe in question.

type Prober

type Prober interface {
	// Probe this thing and return true or false as to it's success.
	// Alternatively an error can be raise when making this decision in which
	// case the probe should be considered a failed with extra context through
	// the error.
	Probe() (bool, error)
}

Prober represents something that can be probed and return a true or false statement about it's success or optionally error if it's not able to assertain a probes success.

var (
	// Failure is a convenience wrapper probe that always evaluates to failure.
	Failure Prober = ProberFn(func() (bool, error) {
		return false, nil
	})

	// NotImplemented is a convenience wrapper for supplying a probe that
	// indiciates to it's caller that it's not implemented. Resulting error
	// will be of type errors.NotImplemented
	NotImplemented Prober = ProberFn(func() (bool, error) {
		return false, errors.NotImplementedf("probe not implemented")
	})

	// Success is a convenience wrapper probe that always evaluates to success.
	Success Prober = ProberFn(func() (bool, error) {
		return true, nil
	})
)

type ProberFn

type ProberFn func() (bool, error)

ProberFn is a convenience wrapper to transform a function into a Prober interface

func (ProberFn) Probe

func (p ProberFn) Probe() (bool, error)

Probe implements Prober interface

type SupportedProbes

type SupportedProbes map[ProbeType]Prober

SupportedProbes provides a map of supported probes to the caller referenced on ProbeType.

func (SupportedProbes) Supports

func (s SupportedProbes) Supports(t ProbeType) bool

Supports indicates if the supplied ProbeType is in the map of supported probe types.

Jump to

Keyboard shortcuts

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