Skip to content

refactor(bulkhead): share validation and rejection logic#100

Merged
lesnik512 merged 2 commits into
mainfrom
worktree-bulkhead-shared-validation-rejection
Jul 13, 2026
Merged

refactor(bulkhead): share validation and rejection logic#100
lesnik512 merged 2 commits into
mainfrom
worktree-bulkhead-shared-validation-rejection

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Extracts Bulkhead/AsyncBulkhead's hand-duplicated constructor validation and on-timeout rejection logic (emit event + construct BulkheadFullError) into two shared functions in bulkhead.py: _validate_bulkhead_config, _emit_bulkhead_rejected.
  • Closes an explicitly-named deferral from this repo's own history (planning/changes/2026-06-23.01-retry-policy-extraction.md's Out-of-scope section).
  • _emit_bulkhead_rejected RETURNS the constructed exception rather than raising it — this preserves the async path's explicit raise ... from exc chaining vs the sync path's bare raise (no active exception to chain from). Two new tests guard this distinction directly (__cause__ is a TimeoutError for async, None for sync) since nothing tested it before.
  • Kept as plain functions, local to bulkhead.py — no state to hold, matching the pattern already used for client.py's request-assembly extraction earlier this session.

Design: planning/changes/2026-07-13.04-bulkhead-shared-validation-rejection.md

Test plan

  • just test — 777 passed (775 existing + 2 new), 100% coverage
  • just lint-ci — ruff format/check, ty check, planning validator all clean
  • Task-scoped review (spec + quality): Approved
  • Final whole-branch review: Ready to merge = Yes, no Critical/Important findings (reviewer independently verified the chaining behavior with an isolated runtime experiment)

…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.
@lesnik512 lesnik512 merged commit 18505e3 into main Jul 13, 2026
11 of 12 checks passed
@lesnik512 lesnik512 deleted the worktree-bulkhead-shared-validation-rejection branch July 13, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant