feat: adding circuit breaker feature#8266
Merged
Merged
Conversation
svozza
reviewed
Jun 9, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #8266 +/- ##
===========================================
+ Coverage 96.58% 96.62% +0.04%
===========================================
Files 286 296 +10
Lines 14298 14686 +388
Branches 1193 1230 +37
===========================================
+ Hits 13810 14191 +381
- Misses 357 360 +3
- Partials 131 135 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
svozza
reviewed
Jun 18, 2026
svozza
approved these changes
Jun 25, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8257
Summary
Changes
This PR adds a Circuit Breaker utility (under the
circuit_breaker_alphanamespace) so a Lambda function can stop calling an unhealthy downstream and let it recover, instead of piling on retries.It ships as alpha on purpose: I want about a month of feedback before we lock the public API and promote it to GA.
The failure counter lives in memory per execution environment, so a healthy circuit writes nothing; we only persist state transitions. State is shared via DynamoDB, fails open if the store is unreachable, and uses a conditional write to elect a single probe during recovery (no thundering herd). You handle rejected requests with an
on_circuit_opencallback and observe state changes with anon_transitionhook.User experience
Before, you had to build the state machine, shared storage, and recovery logic yourself. Now you wrap the function that makes the downstream call:
With no config, sensible defaults apply (open after 5 failures, probe after 30s, close after 3 successes). When open, the call is skipped and the callback's value is returned, or a
CircuitBreakerOpenErroris raised.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.