【文件属性】:
文件名称:breaker:Go中的断路器实现
文件大小:6KB
文件格式:ZIP
更新时间:2021-05-21 09:39:09
Go
Go中的断路器实现
这是我在Go中实现断路器模式的第二次尝试,第一个是
这个版本非常简单惯用
它没有任何外部依赖
受到Nexflix Hystrix的启发
如何使用
b , err := NewBreaker ( OptionsDefaults ())
err = b . Call ( func () error {
// do my logic
return nil
})
if err == ErrBreakerOpen {
// the circuit is open
}
创建断路器时的默认电路值
// OptionsDefaults
// ErrorsPercentage - 50 - If number_of_errors / total_calls * 100 > 50.0 the circuit will be open
// MinimumNumberOfRequ
【文件预览】:
breaker-master
----counters.go(3KB)
----LICENSE(555B)
----README.md(821B)
----breaker_test.go(4KB)
----breaker.go(3KB)
----breaker_bench_test.go(662B)
----counters_test.go(6KB)