Skip to content

feat(circuit breaker): add sliding window for request result tracking #1020

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

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from

Conversation

liuzengh
Copy link
Contributor

No description provided.

Copy link

codecov bot commented May 11, 2025

Codecov Report

Attention: Patch coverage is 95.16129% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.72%. Comparing base (66256ef) to head (f383d5d).

Files with missing lines Patch % Lines
circuit_breaker.go 95.16% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #1020      +/-   ##
==========================================
- Coverage   99.82%   99.72%   -0.10%     
==========================================
  Files          18       18              
  Lines        3919     3961      +42     
==========================================
+ Hits         3912     3950      +38     
- Misses          5        9       +4     
  Partials        2        2              
Flag Coverage Δ
unittests 99.72% <95.16%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@liuzengh
Copy link
Contributor Author

https://failsafe-go.dev/circuit-breaker/#time-based-resolution

Time based circuit breakers use a sliding window to aggregate execution results. As time progresses and newer results are recorded, older results are discarded. In order to maintain space and time efficiency, results are grouped into 10 time slices, each representing 1/10th of the configured failure threshold period. When a time slice is no longer within the thresholding period, its results are discarded. This allows the circuit breaker to operate based on recent results without needing to track the time of each individual execution.

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

Successfully merging this pull request may close these issues.

1 participant