README
¶
breaker
项目简介
- 提供熔断器功能,供各种client(如rpc、http、msyql)等进行熔断
- 提供Go方法供业务在breaker熔断前后进行回调处理
配置说明
- NewGroup(name string,c *Config)当c==nil时则采用默认配置
- 可通过breaker.Init(c *Config)替换默认配置
- 可通过group.Reload(c *Config)进行配置更新
- 默认配置如下所示: _conf = &Config{ Window: xtime.Duration(3 * time.Second), Bucket: 10, Request: 100, K:1.5, }
测试
- 执行当前目录下所有测试文件,测试所有功能
Documentation
¶
Index ¶
Examples ¶
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 { SwitchOff bool // breaker switch,default off. // Google K float64 Window xtime.Duration Bucket int 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.