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

Circuit breaker maxFailures documentation inaccurate #3344

Open
nathanallen-toast opened this issue Jan 9, 2024 · 0 comments
Open

Circuit breaker maxFailures documentation inaccurate #3344

nathanallen-toast opened this issue Jan 9, 2024 · 0 comments

Comments

@nathanallen-toast
Copy link

In the circuit breaker docs, we see the following text under "Closed":

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant