Repository navigation
Commit 80bee92
authored
fix: circuit breaker ignores straggler outcomes, unwraps budget exhaustion, rate-limits circuit.rejected (#167)
* fix: circuit breaker ignores straggler outcomes, unwraps budget exhaustion, rate-limits circuit.rejected
Outcomes now carry an epoch ticket from admission, so a request that finishes
after its circuit changed state no longer reopens, closes or frees the probe
slot. A RetryBudgetExhaustedError is classified by its last_exception.
circuit.rejected is emitted outside the sync lock, at most once per second per
circuit, with a suppressed count.
* test: keep the async straggler harness covered on Python 3.11
On 3.11, awaiting a task that ended with an exception drops coverage line
events in the awaiting frame until its next suspension. The harness tasks
now swallow the breaker's error themselves.
* fix: emit circuit breaker events outside the lock and count rejections per outage
Breaker transitions queue their events and the drivers emit them after
releasing the sync lock, so a logging handler that sends a request through
the same breaker no longer deadlocks. Rejection accounting restarts with
each outage: the first rejection is always emitted and circuit.closed
reports the outage's total in a new rejected attribute.1 parent 75f8544 commit 80bee92
9 files changed
Lines changed: 1153 additions & 115 deletions
File tree
- docs
- src/httpware/middleware/resilience
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| |||
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| 181 | + | |
| 182 | + | |
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
| |||
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
192 | | - | |
| 196 | + | |
193 | 197 | | |
194 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
| |||
0 commit comments