-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implement Advanced Circuit Breaker #1153
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1153 +/- ##
==========================================
+ Coverage 80.67% 80.92% +0.25%
==========================================
Files 233 237 +4
Lines 5427 5499 +72
Branches 922 930 +8
==========================================
+ Hits 4378 4450 +72
Misses 844 844
Partials 205 205
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
| ExecuteCircuitBreaker_V7 | 198.4 ns | 2.78 ns | 3.99 ns | 1.00 | 0.00 | 0.0629 | 528 B | 1.00 | | ||
| ExecuteCircuitBreaker_V8 | 297.9 ns | 2.63 ns | 3.77 ns | 1.50 | 0.04 | 0.0038 | 32 B | 0.06 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that it's slower.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will give this another shot later to see if we can bring it down. Allocations are greatly reduced though, that for us makes bigger impact.
src/Polly.Core/CircuitBreaker/CircuitBreakerResilienceStrategy.cs
Outdated
Show resolved
Hide resolved
_windows.Enqueue(_currentWindow); | ||
} | ||
|
||
while (now - _windows.Peek().StartedAt >= _samplingDuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Peek()
guaranteed to return a non-null value here? Would it be possible for this and Reset()
to race and cause _currentWindow
to become null while the method is running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's executed under a lock. Will add a note to the docs about it.
The issue or feature being addressed
Closes #1098
Details on the issue fix or feature implementation
In this PR I am implementing
AdvancedCircuitBehavior
which finalizes the Circuit Breaker for V8. No public API changes.I have copied and cleaned-up the
RollingHealthMetrics
andSingleHealthMetrics
from Polly V7 to preserve the behavior.Additional changes:
Confirm the following