Skip to content

feat(seatbelt): introduce config for each middleware#302

Merged
martintmk merged 16 commits intomainfrom
seatbelt-config
Mar 5, 2026
Merged

feat(seatbelt): introduce config for each middleware#302
martintmk merged 16 commits intomainfrom
seatbelt-config

Conversation

@martintmk
Copy link
Member

Resolves #301

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (7bf2cb4) to head (a9065aa).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #302   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         144      147    +3     
  Lines        8921     9004   +83     
=======================================
+ Hits         8921     9004   +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds serde-compatible configuration structs and .config() convenience methods to seatbelt middleware so users can load resilience settings from external config files (resolves #301).

Changes:

  • Introduce RetryConfig, BreakerConfig, and TimeoutConfig (serde-gated) and expose them from their modules.
  • Add .config(&...Config) methods on RetryLayer, BreakerLayer, and TimeoutLayer to apply config in one call; refactor enable/disable handling via a shared EnableIf enum.
  • Add a config example (JSON + Rust) and snapshot tests verifying defaults and config application.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/seatbelt/src/utils/mod.rs Replace macro-based EnableIf with an enum supporting enabled/disabled/custom predicate.
crates/seatbelt/src/timeout/mod.rs Add config module and re-export TimeoutConfig.
crates/seatbelt/src/timeout/layer.rs Add TimeoutLayer::config and update enable/disable plumbing + snapshots in tests.
crates/seatbelt/src/timeout/config.rs New serde-gated TimeoutConfig with duration-friendly serde formatting.
crates/seatbelt/src/timeout/snapshots/* New snapshots for timeout defaults and config application.
crates/seatbelt/src/retry/mod.rs Add config module and re-export RetryConfig.
crates/seatbelt/src/retry/layer.rs Add RetryLayer::config applying all config fields.
crates/seatbelt/src/retry/config.rs New serde-gated RetryConfig with duration-friendly serde formatting.
crates/seatbelt/src/retry/backoff.rs Add serde derives for Backoff (feature-gated).
crates/seatbelt/src/retry/service.rs Switch default assertions to snapshots.
crates/seatbelt/src/retry/snapshots/* New snapshots for retry defaults and config application.
crates/seatbelt/src/breaker/mod.rs Add config module and re-export BreakerConfig.
crates/seatbelt/src/breaker/layer.rs Add BreakerLayer::config applying all config fields.
crates/seatbelt/src/breaker/service.rs Switch default assertions to snapshots.
crates/seatbelt/src/breaker/config.rs New serde-gated BreakerConfig with duration-friendly serde formatting.
crates/seatbelt/src/breaker/half_open_mode.rs Add serde representation for HalfOpenMode + serde roundtrip tests.
crates/seatbelt/src/breaker/snapshots/* New snapshots for breaker defaults and config application.
crates/seatbelt/src/fallback/layer.rs Update enable/disable plumbing to new EnableIf.
crates/seatbelt/src/lib.rs Document new serde feature.
crates/seatbelt/examples/config.rs New example showing deserialization + .config() usage.
crates/seatbelt/examples/config.json Example JSON config file.
crates/seatbelt/README.md Document new serde feature.
crates/seatbelt/Cargo.toml Add serde feature, deps (serde, jiff), dev deps (insta, serde_json), and example wiring.
Cargo.lock Lockfile updates for new dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martintmk martintmk merged commit da791c4 into main Mar 5, 2026
27 checks passed
@martintmk martintmk deleted the seatbelt-config branch March 5, 2026 07:21
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.

Seatbelt: add support to configure resilience middleware using serde-compatible configuration

4 participants