Documentation
¶
Index ¶
Constants ¶
View Source
const ( // StateOpen rejects requests according to the calculated drop ratio. StateOpen int32 = iota // StateClosed allows requests while the rolling failure ratio is healthy. StateClosed )
Variables ¶
View Source
var ErrNotAllowed = errors.New("circuitbreaker: not allowed for circuit open")
ErrNotAllowed is returned when the circuit breaker is open.
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is an SRE-style circuit breaker.
func (*Breaker) MarkSuccess ¶
func (b *Breaker) MarkSuccess()
MarkSuccess records a successful request.
type CircuitBreaker ¶
type CircuitBreaker interface {
Allow() error
MarkSuccess()
MarkFailed()
}
CircuitBreaker is a circuit breaker.
func NewBreaker ¶
func NewBreaker(opts ...Option) CircuitBreaker
NewBreaker returns an SRE circuit breaker.
type Option ¶
type Option func(*options)
Option configures the SRE circuit breaker.
func WithBucket ¶
WithBucket sets the number of buckets in the rolling window.
func WithFailureRatio ¶
WithFailureRatio sets the failure ratio threshold that starts rejection.
func WithRequest ¶
WithRequest sets the minimum request count before rejection starts.
func WithWindow ¶
WithWindow sets the rolling statistical window.
Click to show internal directories.
Click to hide internal directories.