tangs b030ce89ca openbilibili | 5 jaren geleden | |
---|---|---|
.. | ||
BUILD.bazel | 5 jaren geleden | |
README.md | 5 jaren geleden | |
breaker.go | 5 jaren geleden |
The circuit-breaker resiliency pattern for golang.
Creating a breaker takes three parameters:
b := breaker.New(3, 1, 5*time.Second)
for {
result := b.Run(func() error {
// communicate with some external service and
// return an error if the communication failed
return nil
})
switch result {
case nil:
// success!
case breaker.ErrBreakerOpen:
// our function wasn't run because the breaker was open
default:
// some other error
}
}