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 ¶
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) 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 ¶
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 SupportedProbes ¶
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.