You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an exception occurs, it increments the failure counter.
When the failure counter reaches the given maxFailures threshold, the breaker moves to the Open state.
This seems to be saying that the breaker will open as soon as it sees that specified number of failures. Indeed, the example given later shows maxFailures being set to 2 (via openingStrategy = OpeningStrategy.Count(2)), and the circuit opening after seeing two failures.
However, the actual code behaves as follows:
fun Count.shouldOpen(): Boolean= failuresCount > maxFailures
fun SlidingWindow.shouldOpen(): Boolean=
maxFailures < failures.size && failures.firstOrNull()?.plus(windowDuration)?.hasNotPassedNow() ==true
}
As implemented, we require failuresCount to be greater than, rather than equal to, maxFailures for the breaker to open.
I'm happy to go in and fix this myself, but I suspect that there are users of this library who rely on this behavior. Changing the docs would be an easier solution, but that leaves OpeningStrategy with (in my opinion) a confusingly named parameter.
The text was updated successfully, but these errors were encountered:
In the circuit breaker docs, we see the following text under "Closed":
This seems to be saying that the breaker will open as soon as it sees that specified number of failures. Indeed, the example given later shows
maxFailures
being set to 2 (viaopeningStrategy = OpeningStrategy.Count(2)
), and the circuit opening after seeing two failures.However, the actual code behaves as follows:
As implemented, we require
failuresCount
to be greater than, rather than equal to,maxFailures
for the breaker to open.I'm happy to go in and fix this myself, but I suspect that there are users of this library who rely on this behavior. Changing the docs would be an easier solution, but that leaves
OpeningStrategy
with (in my opinion) a confusingly named parameter.The text was updated successfully, but these errors were encountered: