mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
fix: didn't count failure in allow method with breaker algorithm (#4008)
This commit is contained in:
@@ -31,9 +31,10 @@ type (
|
|||||||
Name() string
|
Name() string
|
||||||
|
|
||||||
// Allow checks if the request is allowed.
|
// Allow checks if the request is allowed.
|
||||||
// If allowed, a promise will be returned, the caller needs to call promise.Accept()
|
// If allowed, a promise will be returned,
|
||||||
// on success, or call promise.Reject() on failure.
|
// otherwise ErrServiceUnavailable will be returned as the error.
|
||||||
// If not allow, ErrServiceUnavailable will be returned.
|
// The caller needs to call promise.Accept() on success,
|
||||||
|
// or call promise.Reject() on failure.
|
||||||
Allow() (Promise, error)
|
Allow() (Promise, error)
|
||||||
|
|
||||||
// Do runs the given request if the Breaker accepts it.
|
// Do runs the given request if the Breaker accepts it.
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ func (b *googleBreaker) accept() error {
|
|||||||
|
|
||||||
func (b *googleBreaker) allow() (internalPromise, error) {
|
func (b *googleBreaker) allow() (internalPromise, error) {
|
||||||
if err := b.accept(); err != nil {
|
if err := b.accept(); err != nil {
|
||||||
|
b.markFailure()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user