Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in circuit_breaker.go about SlowRequestRatio #315

Merged
merged 6 commits into from
Nov 5, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/circuitbreaker/circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ func (b *slowRtCircuitBreaker) OnRequestComplete(rt uint64, err error) {
return
}

if slowRatio > b.maxSlowRequestRatio {
// Special case when maxSlowRequestRatio is set to 1.0 should be handled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to change checking logic.
Using "slowRatio >= b.maxSlowRequestRatio"、”errorRatio >= b.errorRatioThreshold“ and ”errorCount >= b.errorCountThreshold“

It's easier to understand.

if slowRatio > b.maxSlowRequestRatio || (slowRatio == 1.0 && b.maxSlowRequestRatio == 1.0) {
curStatus = b.CurrentState()
switch curStatus {
case Closed:
Expand Down Expand Up @@ -468,7 +469,8 @@ func (b *errorRatioCircuitBreaker) OnRequestComplete(rt uint64, err error) {
if totalCount < b.minRequestAmount {
return
}
if errorRatio > b.errorRatioThreshold {
// Special case when errorRatioThreshold is set to 1.0 should be handled
if errorRatio > b.errorRatioThreshold || (b.errorRatioThreshold == 1.0 && errorRatio == 1.0) {
curStatus = b.CurrentState()
switch curStatus {
case Closed:
Expand Down