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 the succeed ratio, if request num greater request setting and // ratio lower than the setting ratio, then reset state to open. StateClosed // StateHalfopen when circuit breaker open, after slepp some duration, allow // one request, but not state closed. StateHalfopen )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Breaker ¶
type Breaker interface { Allow() error MarkSuccess() MarkFailed() }
Breaker is a CircuitBreaker pattern. FIXME on int32 atomic.LoadInt32(&b.on) == _switchOn
type Config ¶
type Config struct { // breaker switch // set true to close breaker SwitchOff bool // Google K float64 // 统计时间窗口 // 默认值 5s Window time.Duration Bucket int // 熔断触发临界请求量 // 统计窗口内请求量低于Request值则不触发熔断 // 默认值 20 Request int64 }
Config broker config.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a class of CircuitBreaker and forms a namespace in which units of CircuitBreaker.
func (*Group) Get ¶
Get get a breaker by a specified key, if breaker not exists then make a new one.
Click to show internal directories.
Click to hide internal directories.