Documentation ¶
Index ¶
Constants ¶
View Source
const ( // StateOpen when circuit breaker open, request not allowed, after sleep // some duration, allow one single request for testing the health, if ok // then state reset to closed, if not continue the step. StateOpen int32 = iota // StateClosed when circuit breaker closed, request allowed, the breaker // calc to succeed ratio, if request num greater request setting and // ratio lower than the setting ratio, then reset state to open. StateClosed )
Variables ¶
This section is empty.
Functions ¶
func NewBreaker ¶
func NewBreaker(opts ...Option) circuitbreaker.CircuitBreaker
NewBreaker return a sreBreaker with options
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is a sre CircuitBreaker pattern.
type Option ¶
type Option func(*options)
Option is sre breaker option function.
func WithBucket ¶
WithBucket set the bucket number in a window duration.
func WithRequest ¶
WithRequest with the minimum number of requests allowed.
func WithSuccess ¶
WithSuccess with the K = 1 / Success value of sre breaker, default success is 0.5 Reducing the K will make adaptive throttling behave more aggressively, Increasing the K will make adaptive throttling behave less aggressively.
func WithWindow ¶
WithWindow with the duration size of the statistical window.
Click to show internal directories.
Click to hide internal directories.