Documentation
¶
Overview ¶
Package runner periodically executes a Probe and pushes the result into a State, invoking Reporters on transitions. Decouples probe execution from transport — transports read cached State instead of running checks per-request (matters for gRPC Watch, expensive checks, or bursty traffic).
Index ¶
Constants ¶
const ( DefaultInterval = 5 * time.Second DefaultTimeout = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Runner)
Option configures a Runner.
func RunImmediately ¶
func RunImmediately() Option
RunImmediately performs an initial check before the first tick. Default: false (state stays StatusUnknown until first tick).
func WithInterval ¶
func WithReporter ¶
func WithTimeout ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner polls a probe.Probe and updates a state.State.
Every evaluation — a scheduled tick or an explicit Check — runs under one mutex held across the probe call, the State update and the reporter call, so results land in State (and reach the reporter) strictly in evaluation order. A Runner must not be copied after first use.
func (*Runner) Check ¶ added in v1.1.0
Check evaluates the probe right now, outside the tick schedule, and returns the resulting status. It behaves exactly like a tick: the probe is bounded by the configured timeout (StatusTimeout on expiry), the result is stored in State, and the reporter fires on a transition.
Check is safe to call before Run and concurrently with it; evaluations are serialized, so a Check waits for an in-flight tick (and vice versa) and the State always holds the result of the latest evaluation.
If ctx is canceled (before or during the evaluation), nothing is stored and no reporter fires — as with a tick on shutdown — and Check returns the current cached status: StatusUnknown if State has never been set.