Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultBackoff = Backoff{ Base: 100 * time.Millisecond, Max: 30 * time.Second, Multiplier: 2.0, Jitter: true, }
View Source
var DefaultRetry = RetryConfig{ MaxAttempts: 3, Backoff: DefaultBackoff, }
View Source
var ErrCircuitOpen = errors.New("circuit breaker is open")
Functions ¶
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker stops calling a failing service to give it time to recover.
func NewCircuitBreaker ¶
func NewCircuitBreaker(maxFailures int, timeout time.Duration) *CircuitBreaker
func (*CircuitBreaker) Execute ¶
func (cb *CircuitBreaker) Execute(fn func() error) error
Execute runs fn if the circuit allows it. In half-open state only one trial request is allowed at a time.
type RetryConfig ¶
RetryConfig controls how retries behave.
Click to show internal directories.
Click to hide internal directories.