Skip to content

feat(breaker): add a shared circuit breaker and retry with jitter - #373

Merged
patdowney merged 2 commits into
masterfrom
feat/breaker
Nov 15, 2026
Merged

patdowney merged 2 commits into
masterfrom
feat/breaker

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

Closes #368.

Changes

New package breaker:

  • connect-control's consecutive-failure breaker, with its tests unchanged (closed, open, half-open with a single trial, injectable clock, IsFailure, OnStateChange, Health, ErrOpen). Extra tests cover IsFailure, the transition sequence, one trial under concurrency and State.String.
  • Retry(ctx, RetryConfig, fn): capped exponential backoff, full jitter by default (NoJitter to disable), caller-supplied Retryable (default skips ErrOpen and cancellation), logger from zerolog.Ctx(ctx), stops promptly on cancellation.
  • An example shows Health as a lifecycle degraded check; the package itself does not import lifecycle.

Testing

go test -race ./..., golangci-lint and gosec pass.

Consumers need a release of dioad/net first; each adopter should delete its local copy in the same change.

🤖 Generated with Claude Code

patdowney and others added 2 commits November 15, 2026 23:10
The breaker package's Health example uses lifecycle.WithDegraded, which v0.1.0
does not have.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Package breaker is connect-control's consecutive-failure breaker (closed, open,
half-open with a single trial, injectable clock, IsFailure and OnStateChange),
moved with its tests unchanged, plus Retry: exponential backoff with a cap, full
jitter by default, a caller-supplied retryable classifier, a context-carried
logger and prompt stop on cancellation. Breaker.Health fits lifecycle.CheckFunc
without the package importing lifecycle.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@patdowney
patdowney merged commit 66b6a02 into master Nov 15, 2026
5 checks passed
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.

Shared circuit breaker, and retry with backoff and jitter, for calls to dependencies

1 participant