Documentation
¶
Overview ¶
Package breaker provides a per-tier circuit breaker with a sliding-window failure counter, hand-rolled with no external dependencies.
States:
CLOSED — normal operation; Allow() returns true.
OPEN — tripped; Allow() returns false until cooldown elapses.
HALF-OPEN — cooldown elapsed; exactly ONE probe is allowed through; a
successful Record closes the breaker, a failed one re-opens it.
The sliding window tracks the last windowSize outcomes (bool ring buffer). The breaker trips to OPEN when failures within that window reach failureThreshold.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is a single-tier circuit breaker.
func New ¶
New creates a Breaker.
- failureThreshold: number of failures in the sliding window that trips OPEN.
- windowSize: size of the outcome ring buffer.
- cooldown: how long the breaker stays OPEN before transitioning to HALF-OPEN.
func (*Breaker) Allow ¶
Allow returns true if a call may proceed. While OPEN it returns false; in HALF-OPEN exactly one probe is allowed.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group manages a set of Breakers keyed by tier name.
Click to show internal directories.
Click to hide internal directories.