Skip to content

feat(circuit-breaker): read-only state introspection (0.14.0)#70

Merged
lesnik512 merged 3 commits into
mainfrom
feat/circuit-breaker-state
Jun 16, 2026
Merged

feat(circuit-breaker): read-only state introspection (0.14.0)#70
lesnik512 merged 3 commits into
mainfrom
feat/circuit-breaker-state

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Exposes the circuit breaker's current state read-only, via a public CircuitState enum and a state property on both AsyncCircuitBreaker and CircuitBreaker — for health/readiness endpoints, dashboards, and tests.

from httpware import CircuitState
from httpware.middleware.resilience import AsyncCircuitBreaker

breaker = AsyncCircuitBreaker(failure_threshold=5)
# ... in a readiness handler:
if breaker.state is CircuitState.OPEN:
    ...  # report the dependency as degraded

Closes the cheap half of the deferred CircuitBreaker introspection item (manual control force_open/force_closed stays deferred). Ships as 0.14.0 (additive, no breaking changes).

What's in it

  • Public CircuitState enum — promoted from the private _CircuitState (CLOSED/OPEN/HALF_OPEN); exported from httpware and httpware.middleware.resilience.
  • state property on both wrappers — a pure read of the stored state: no lock, no clock, and it never triggers the lazy OPEN→HALF_OPEN transition (that stays in admit, on the next request after reset_timeout). So state reports OPEN until a request is actually admitted as the probe — documented as the raw-read caveat.
  • Docsarchitecture/resilience.md, docs/resilience.md, and 0.14.0 release notes.

No behavior change to either trip mode; version is tag-driven, so pyproject.toml is untouched.

Design + plan: planning/changes/active/2026-06-16.03-circuit-breaker-state/.

Test plan

  • just test — 704 passed, 100% coverage
  • just lint — clean (ruff format/check + ty)
  • State tests (async + sync): CLOSED → OPEN → HALF_OPEN → CLOSED lifecycle; raw-read caveat (stays OPEN past reset_timeout with no request); public-API export + identity
  • Classic + rate-mode behavior unchanged
  • mkdocs build --strict — clean

🤖 Generated with Claude Code

lesnik512 and others added 3 commits June 16, 2026 15:34
…perty

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…otes

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Design + plan for the read-only state property + public CircuitState enum,
and the Active Index entry. Bundle stays active/draft until merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 8521a2d into main Jun 16, 2026
5 checks passed
@lesnik512 lesnik512 deleted the feat/circuit-breaker-state branch June 16, 2026 12:44
lesnik512 added a commit that referenced this pull request Jun 16, 2026
Post-merge bookkeeping for PR #70: fill the 0.14.0 release-notes PR number,
mark the bundle shipped (pr: 70), move it active -> archive, flip its Index
line to Archived, and trim the deferred CircuitBreaker entry to just manual
control now that read-only state has shipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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