Documentation
¶
Overview ¶
Package probe contains utilities for health probing, as well as health status information.
Index ¶
- Constants
- type ResultFunc
- type StatusChangedFunc
- type Worker
- type WorkerOption
- func WorkerFailureThreshold(v int) WorkerOption
- func WorkerInitialDelay(delay time.Duration) WorkerOption
- func WorkerOnProbeResult(f ResultFunc) WorkerOption
- func WorkerOnStatusChange(f StatusChangedFunc) WorkerOption
- func WorkerPeriod(period time.Duration) WorkerOption
- func WorkerSuccessThreshold(v int) WorkerOption
- func WorkerTimeout(timeout time.Duration) WorkerOption
Constants ¶
const ( // DefaultProbePeriod is the default value for the interval between // probe invocations. DefaultProbePeriod = 10 * time.Second // DefaultProbeTimeout is the default value for the timeout when // executing a probe to cancel it and consider it failed. DefaultProbeTimeout = 1 * time.Second // DefaultInitialDelay is the default value for the initial delay // before beginning to invoke the probe after the Worker is started. DefaultInitialDelay = 0 * time.Second // DefaultProbeSuccessThreshold is the default value for the // minimum number of consecutive successes required after having // failed before the status will transition to probe.Success. DefaultProbeSuccessThreshold = 1 // DefaultProbeFailureThreshold is the default value for the // minimum number of consecutive failures required after having // succeeded before the status will transition to probe.Failure. DefaultProbeFailureThreshold = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResultFunc ¶ added in v0.2.0
ProbeResultFunc is invoked on every probe execution using WorkerOnProbeResult.
type StatusChangedFunc ¶
StatusChangedFunc is invoked on status transitions using WorkerOnStatusChange.
It will NOT be called for subsequent probe invocations that do not result in a status change.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker handles executing probes and reporting results.
It's loosely based (but simplified) on the k8s.io/kubernetes/pkg/kubelet/prober design.
func NewWorker ¶
func NewWorker(p prober.Prober, opts ...WorkerOption) *Worker
NewWorker creates a Worker instance using the provided probe.Prober and options (if any).
type WorkerOption ¶
type WorkerOption func(w *Worker)
WorkerOption can be passed when creating a Worker to configure the instance.
func WorkerFailureThreshold ¶
func WorkerFailureThreshold(v int) WorkerOption
WorkerFailureThreshold sets the number of consecutive failures required after a probe has succeeded before the status will transition to probe.Failure.
func WorkerInitialDelay ¶
func WorkerInitialDelay(delay time.Duration) WorkerOption
WorkerInitialDelay sets the amount of time that will be waited when the prober starts before beginning to invoke the probe.
The status will be probe.Failure during the initial delay period.
func WorkerOnProbeResult ¶ added in v0.2.0
func WorkerOnProbeResult(f ResultFunc) WorkerOption
WorkerOnProbeResult sets the function to invoke after every probe execution regardless of whether it results in a status transition.
func WorkerOnStatusChange ¶
func WorkerOnStatusChange(f StatusChangedFunc) WorkerOption
WorkerOnStatusChange sets the function to invoke when the status transitions.
Subsequent probe invocations that do not result in a change to the status (either because they return the same result or the failure/ success threshold has not been met) will not emit a status change update.
func WorkerPeriod ¶
func WorkerPeriod(period time.Duration) WorkerOption
WorkerPeriod sets the period between probe invocations.
func WorkerSuccessThreshold ¶
func WorkerSuccessThreshold(v int) WorkerOption
WorkerSuccessThreshold sets the number of consecutive successes required after a probe has failed before the status will transition to probe.Success.
func WorkerTimeout ¶
func WorkerTimeout(timeout time.Duration) WorkerOption
WorkerTimeout sets the duration before a running probe is canceled and considered to have failed.