mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-25 14:26:04 +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
|
LastActivity() time.Time
|
||||||
Reset()
|
Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type counters struct {
|
||||||
|
ConsecutiveFailures uint32
|
||||||
|
ConsecutiveSuccesses uint32
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Circuit Breaker
|
### Circuit Breaker
|
||||||
@ -60,21 +66,6 @@ import (
|
|||||||
"time"
|
"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
|
type Circuit func(context.Context) error
|
||||||
|
|
||||||
var canRetry = func(cnt counters, failureThreshold uint32) bool {
|
var canRetry = func(cnt counters, failureThreshold uint32) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user