mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-25 06:16:03 +03:00
Update circuit-breaker.md
This commit is contained in:
parent
33e5b0d51a
commit
064adb67c2
@ -41,6 +41,12 @@ type Counter interface {
|
||||
LastActivity() time.Time
|
||||
Reset()
|
||||
}
|
||||
|
||||
type counters struct {
|
||||
ConsecutiveFailures uint32
|
||||
ConsecutiveSuccesses uint32
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Circuit Breaker
|
||||
@ -60,21 +66,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type State int
|
||||
|
||||
const (
|
||||
UnknownState State = iota
|
||||
FailureState
|
||||
SuccessState
|
||||
)
|
||||
|
||||
type Counter interface {
|
||||
Count(State)
|
||||
ConsecutiveFailures() uint32
|
||||
LastActivity() time.Time
|
||||
Reset()
|
||||
}
|
||||
|
||||
type Circuit func(context.Context) error
|
||||
|
||||
var canRetry = func(cnt counters, failureThreshold uint32) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user