Documentation
¶
Overview ¶
Package cb - For when your dependencies are as reliable as a chocolate teapot
Index ¶
- Constants
- type CircuitBreaker
- func (cb *CircuitBreaker) Execute(fn func() error) error
- func (cb *CircuitBreaker) Failures() int64
- func (cb *CircuitBreaker) IsClosed() bool
- func (cb *CircuitBreaker) IsHalfOpen() bool
- func (cb *CircuitBreaker) IsOpen() bool
- func (cb *CircuitBreaker) LastFailure() time.Time
- func (cb *CircuitBreaker) Reset()
- func (cb *CircuitBreaker) SetThreshold(threshold int64)
- func (cb *CircuitBreaker) SetTimeout(timeout time.Duration)
- func (cb *CircuitBreaker) String() string
- func (cb *CircuitBreaker) Threshold() int64
- func (cb *CircuitBreaker) Timeout() time.Duration
Constants ¶
View Source
const (
ErrCircuitOpen = "circuit breaker is open"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker implements the "nope, not gonna try that again" pattern It's like a bouncer for your function calls
func NewCircuitBreaker ¶
func NewCircuitBreaker(threshold int64, timeout time.Duration) *CircuitBreaker
NewCircuitBreaker creates a new failure detection system threshold: how many times you're willing to get hurt timeout: how long you need to recover from trust issues
func (*CircuitBreaker) Execute ¶
func (cb *CircuitBreaker) Execute(fn func() error) error
Execute attempts to run your probably-going-to-fail function Returns error when it inevitably breaks
func (*CircuitBreaker) Failures ¶
func (cb *CircuitBreaker) Failures() int64
func (*CircuitBreaker) IsClosed ¶
func (cb *CircuitBreaker) IsClosed() bool
func (*CircuitBreaker) IsHalfOpen ¶
func (cb *CircuitBreaker) IsHalfOpen() bool
func (*CircuitBreaker) IsOpen ¶
func (cb *CircuitBreaker) IsOpen() bool
func (*CircuitBreaker) LastFailure ¶
func (cb *CircuitBreaker) LastFailure() time.Time
func (*CircuitBreaker) Reset ¶
func (cb *CircuitBreaker) Reset()
func (*CircuitBreaker) SetThreshold ¶
func (cb *CircuitBreaker) SetThreshold(threshold int64)
func (*CircuitBreaker) SetTimeout ¶
func (cb *CircuitBreaker) SetTimeout(timeout time.Duration)
func (*CircuitBreaker) String ¶
func (cb *CircuitBreaker) String() string
func (*CircuitBreaker) Threshold ¶
func (cb *CircuitBreaker) Threshold() int64
func (*CircuitBreaker) Timeout ¶
func (cb *CircuitBreaker) Timeout() time.Duration
Click to show internal directories.
Click to hide internal directories.