mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-08-10 00:05:46 +08:00
add vendor packages避免用户网络太慢无法下载编译
This commit is contained in:
34
vendor/github.com/eapache/go-resiliency/breaker/README.md
generated
vendored
Normal file
34
vendor/github.com/eapache/go-resiliency/breaker/README.md
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
circuit-breaker
|
||||
===============
|
||||
|
||||
[](https://travis-ci.org/eapache/go-resiliency)
|
||||
[](https://godoc.org/github.com/eapache/go-resiliency/breaker)
|
||||
[](https://eapache.github.io/conduct.html)
|
||||
|
||||
The circuit-breaker resiliency pattern for golang.
|
||||
|
||||
Creating a breaker takes three parameters:
|
||||
- error threshold (for opening the breaker)
|
||||
- success threshold (for closing the breaker)
|
||||
- timeout (how long to keep the breaker open)
|
||||
|
||||
```go
|
||||
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
|
||||
}
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user