Update circuit-breaker.md

This commit is contained in:
Edward 2020-05-22 14:18:17 +08:00 committed by GitHub
parent 33e5b0d51a
commit 064adb67c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {