Documentation
¶
Overview ¶
Package breaker implements the shard-level circuit breaker: a rolling count-based window of request outcomes, the CLOSED → OPEN → HALF-OPEN state machine, and half-open probe accounting. Network and hard errors count toward opening the breaker; OK and soft outcomes do not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker interface {
// Allow reports whether a request may be dispatched. In half-open
// state the first GetBreakerProbes() requests become the probes;
// everything else is fast-failed, like in the open state.
Allow() bool
// Record feeds a dispatched request's outcome into the window.
// Fast-failed requests must not be recorded.
Record(o Outcome)
State() State
// OnTransition registers a callback invoked (outside the lock) on
// every state change, for logging and transition counters.
OnTransition(func(from, to State))
}
Breaker is one shard's circuit breaker.
func NewShardBreaker ¶
NewShardBreaker returns a breaker with an empty window in the closed state.
type Config ¶
type Config interface {
GetBreakerErrorThreshold() float64
GetBreakerWindow() int
GetBreakerOpenDuration() time.Duration
GetBreakerProbes() int
}
Config is the layer-A interface the breaker consumes, read on the fly.
Click to show internal directories.
Click to hide internal directories.