Versions in this module Expand all Collapse all v1 v1.1.0 Mar 15, 2026 v1.0.1 Nov 22, 2025 Changes in this version + var ErrCircuitOpen = errors.New("circuit breaker is open") + var ErrTooManyRequests = errors.New("too many requests in half-open state") + type CircuitBreaker struct + func New(config *Config) *CircuitBreaker + func (cb *CircuitBreaker) Call(ctx context.Context, fn func() error) error + func (cb *CircuitBreaker) Name() string + func (cb *CircuitBreaker) Reset() + func (cb *CircuitBreaker) State() State + func (cb *CircuitBreaker) Stats() Stats + type Config struct + MaxFailures uint32 + MaxRequestsHalfOpen uint32 + Name string + OnStateChange func(from, to State) + Timeout time.Duration + func DefaultConfig(name string) *Config + type State int + const StateClosed + const StateHalfOpen + const StateOpen + func (s State) String() string + type Stats struct + ConsecutiveFailures uint32 + ConsecutiveSuccesses uint32 + LastFailure time.Time + LastStateChange time.Time + State State + TotalFailures uint64 + TotalRequests uint64 + TotalSuccesses uint64