Documentation
¶
Index ¶
- Variables
- type Breaker
- type CircuitBreakerDriver
- func (d *CircuitBreakerDriver) Flush(ctx context.Context) error
- func (d *CircuitBreakerDriver) Forget(ctx context.Context, key string) error
- func (d *CircuitBreakerDriver) Get(ctx context.Context, key string) (interface{}, error)
- func (d *CircuitBreakerDriver) Put(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- type State
- type ThresholdBreaker
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCircuitOpen is returned when the circuit breaker is open. ErrCircuitOpen = errors.New("circuit breaker is open") )
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker interface {
// Allow checks if the request is allowed to proceed.
Allow() bool
// Success reports a successful execution.
Success()
// Failure reports a failed execution.
Failure()
}
Breaker defines the interface for a circuit breaker.
type CircuitBreakerDriver ¶
CircuitBreakerDriver wraps a cache driver with a circuit breaker.
func NewCircuitBreakerDriver ¶
func NewCircuitBreakerDriver(driver cache.Driver, breaker Breaker) *CircuitBreakerDriver
NewCircuitBreakerDriver creates a new CircuitBreakerDriver.
func (*CircuitBreakerDriver) Flush ¶
func (d *CircuitBreakerDriver) Flush(ctx context.Context) error
func (*CircuitBreakerDriver) Forget ¶
func (d *CircuitBreakerDriver) Forget(ctx context.Context, key string) error
type ThresholdBreaker ¶
type ThresholdBreaker struct {
// contains filtered or unexported fields
}
ThresholdBreaker implements a simple failure threshold circuit breaker.
func NewThresholdBreaker ¶
func NewThresholdBreaker(threshold int, timeout time.Duration) *ThresholdBreaker
NewThresholdBreaker creates a new ThresholdBreaker.
func (*ThresholdBreaker) Allow ¶
func (b *ThresholdBreaker) Allow() bool
Allow checks if the request is allowed.
Click to show internal directories.
Click to hide internal directories.