Documentation
¶
Overview ¶
Package resilience provides circuit breakers and bounded concurrency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBulkheadFull = errors.New("resilience: bulkhead queue full")
var ErrOpen = errors.New("resilience: circuit open")
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker coordinates concurrency-safe circuit-breaker state.
func New ¶
New constructs and validates an explicitly owned instance. See package documentation for defaults and cleanup.
type Bulkhead ¶
type Bulkhead struct {
// contains filtered or unexported fields
}
Bulkhead bounds concurrency and memory attributable to queued admissions.
func NewBulkhead ¶
NewBulkhead preserves cancellable waiting with a finite default queue of 1024 operations.
func NewBulkheadWithConfig ¶
func NewBulkheadWithConfig(c BulkheadConfig) (*Bulkhead, error)
NewBulkheadWithConfig validates and creates an independently usable admission policy.
func (*Bulkhead) Do ¶
Do executes an operation after bounded admission. Context cancellation interrupts queued waiting.
func (*Bulkhead) Stats ¶
func (b *Bulkhead) Stats() BulkheadStats
Stats is a concurrency-safe observational snapshot; current counters may change immediately after return.
type BulkheadConfig ¶
type BulkheadConfig struct {
Concurrency, Queue int
Observer instrument.Hook
}
BulkheadConfig bounds both executing operations and admitted waiters. Zero Queue means no waiting.
type BulkheadStats ¶
type BulkheadStats struct{ Active, Queued, Completed, Rejected int64 }
BulkheadStats exposes cumulative completion/rejection and current execution/queue counters.
type Config ¶
type Config struct {
Observer instrument.Hook
FailureThreshold, MinimumRequests, HalfOpenProbes int
FailureRate float64
Recovery time.Duration
OnChange func(State, State)
Failure func(error) bool
}
Config contains explicit constructor settings; see package documentation for defaults.