Documentation
¶
Overview ¶
Package breaker implements a per-provider circuit breaker so a single failing upstream never gets hammered with retries and never blocks requests from reaching healthy providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks circuit breaker state for every known provider ID.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates an empty breaker registry; providers register lazily on first use.
func (*Registry) Allow ¶
Allow reports whether a request may currently be attempted against the given provider. A provider in "open" state is allowed exactly once per cooldown window (the half-open trial) — and, once that trial is admitted, no further request is allowed until the trial's outcome is reported (or halfOpenTrialTimeout elapses without one), so concurrent callers can never all pile onto an upstream that's still recovering.
func (*Registry) IsHalfOpen ¶
IsHalfOpen reports whether a provider is currently in its half-open trial window — allowed through by Allow(), but not yet proven healthy again. Scoring strategies use this to treat a half-open candidate more cautiously than a fully closed one, without excluding it outright.
func (*Registry) IsOpen ¶
IsOpen reports whether a provider is currently tripped (for status/telemetry).
func (*Registry) ReportFailure ¶
ReportFailure records a failed attempt, tripping the breaker open once the consecutive-failure threshold is reached (or immediately, if the failing attempt was itself a half-open trial).
func (*Registry) ReportSuccess ¶
ReportSuccess resets a provider back to a healthy, closed state.