refactor(bulkhead): share validation and rejection logic#100
Merged
Conversation
…head/AsyncBulkhead Extract _validate_bulkhead_config and _emit_bulkhead_rejected as module-level functions so both __init__s and __call__s stop hand-duplicating the same if/raise and emit-event/raise blocks. _emit_bulkhead_rejected returns the exception rather than raising it, since AsyncBulkhead's timeout path needs `raise ... from exc` while Bulkhead's not-acquired path has no exception to chain from. Adds two tests pinning that chaining behavior: AsyncBulkhead's BulkheadFullError has __cause__ set to the TimeoutError; Bulkhead's has __cause__ None.
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.
Summary
_validate_bulkhead_config,_emit_bulkhead_rejected.planning/changes/2026-06-23.01-retry-policy-extraction.md's Out-of-scope section)._emit_bulkhead_rejectedRETURNS the constructed exception rather than raising it — this preserves the async path's explicitraise ... from excchaining vs the sync path's bare raise (no active exception to chain from). Two new tests guard this distinction directly (__cause__is aTimeoutErrorfor async,Nonefor sync) since nothing tested it before.Design:
planning/changes/2026-07-13.04-bulkhead-shared-validation-rejection.mdTest plan
just test— 777 passed (775 existing + 2 new), 100% coveragejust lint-ci— ruff format/check,ty check, planning validator all clean