Skip to content

feat: introduce seatbelt_http crate#428

Open
martintmk wants to merge 14 commits into
mainfrom
seatbelt_http
Open

feat: introduce seatbelt_http crate#428
martintmk wants to merge 14 commits into
mainfrom
seatbelt_http

Conversation

@martintmk
Copy link
Copy Markdown
Member

@martintmk martintmk commented May 18, 2026

feat(seatbelt_http): introduce seatbelt_http crate

Adds a new seatbelt_http crate that specializes the generic seatbelt resilience middleware for HTTP request/response types from http_extensions, and provides HTTP-aware builder methods (all prefixed with http_).

What's included

Feature-gated modules, each with specialized type aliases and an extension trait:

Module Feature Purpose
retry retry Recovery classification, request cloning, request restoration from errors.
timeout timeout Converts timeout events into HTTP-specific errors.
hedging hedging Recovery classification and request cloning for tail-latency reduction.
breaker breaker Recovery classification and rejected-request error handling.

Shared types:

  • HttpRecovery — classifies 5xx, 429, and timeouts as transient by default.
  • HttpClone — selects which HTTP methods are eligible for cloning during retries/hedging (safe-only, idempotent, or all).
  • HttpResilienceContext — HTTP specialization of seatbelt::ResilienceContext.

Example

use http::StatusCode;
use http_extensions::{HttpResponse, ResponseExt};
use seatbelt::RecoveryInfo;
use seatbelt_http::HttpRecovery;
use seatbelt_http::retry::{HttpRetryLayer, HttpRetryLayerExt};

fn configure(layer: HttpRetryLayer) {
    // Default: retry 5xx, 429, and timeouts.
    let _ = layer.clone().http_recovery(HttpRecovery::default());

    // Or a custom classifier:
    let _ = layer.http_recovery(|response: &HttpResponse| {
        if response.status() == StatusCode::TOO_MANY_REQUESTS {
            return RecoveryInfo::never();
        }
        response.recovery()
    });
}

Changes

  • New crate crates/seatbelt_http (initial release 0.2.0).
  • Added to workspace Cargo.toml and root README.md.
  • Changelog and spellcheck entries updated.
    `

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (b5900ac) to head (cbe07cb).

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #428    +/-   ##
========================================
  Coverage   100.0%   100.0%            
========================================
  Files         286      292     +6     
  Lines       22978    23100   +122     
========================================
+ Hits        22978    23100   +122     

☔ 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

⚠️ Breaking Changes Detected

error: failed to retrieve local crate data from git revision

Caused by:
    0: failed to retrieve manifest file from git revision source
    1: possibly due to errors: [
         failed when reading /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/372167fc8c6a5f23d81f716e0394d6162653999d/scripts/crate-template/Cargo.toml: TOML parse error at line 9, column 26
         |
       9 | keywords = ["oxidizer", {{CRATE_KEYWORDS}}]
         |                          ^
       missing key for inline table element, expected key
       : TOML parse error at line 9, column 26
         |
       9 | keywords = ["oxidizer", {{CRATE_KEYWORDS}}]
         |                          ^
       missing key for inline table element, expected key
       ,
         failed to parse /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/372167fc8c6a5f23d81f716e0394d6162653999d/Cargo.toml: no `package` table,
       ]
    2: package `seatbelt_http` not found in /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/372167fc8c6a5f23d81f716e0394d6162653999d

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: cargo_semver_checks::rustdoc_gen::RustdocFromProjectRoot::get_crate_source
   2: cargo_semver_checks::rustdoc_gen::StatefulRustdocGenerator<cargo_semver_checks::rustdoc_gen::CoupledState>::prepare_generator
   3: cargo_semver_checks::Check::check_release::{{closure}}
   4: cargo_semver_checks::Check::check_release
   5: cargo_semver_checks::exit_on_error
   6: cargo_semver_checks::main
   7: std::sys::backtrace::__rust_begin_short_backtrace
   8: main
   9: <unknown>
  10: __libc_start_main
  11: _start

If the breaking changes are intentional then everything is fine - this message is merely informative.

Remember to apply a version number bump with the correct severity when publishing a version with breaking changes (1.x.x -> 2.x.x or 0.1.x -> 0.2.x).

@martintmk martintmk force-pushed the seatbelt_http branch 4 times, most recently from 1c174e4 to 639ebdc Compare May 18, 2026 19:59
@martintmk martintmk marked this pull request as ready for review May 19, 2026 10:07
Copilot AI review requested due to automatic review settings May 19, 2026 10:07
Copy link
Copy Markdown
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

This PR introduces a new seatbelt_http crate that adapts the generic seatbelt resilience middleware to http_extensions request/response types, providing HTTP-aware builder/extension methods (prefixed with http_) for retry, timeout, hedging, and circuit breaker scenarios.

Changes:

  • Added new crates/seatbelt_http crate with feature-gated modules (retry, timeout, hedging, breaker) plus shared HTTP utilities (HttpRecovery, HttpClone, HttpResilienceContext).
  • Wired the crate into the workspace (dependency entry + lockfile) and surfaced it in the root README/changelog index.
  • Updated repository spellcheck allowlist for common HTTP terminology (5xx).

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Adds seatbelt_http to the top-level crate list.
CHANGELOG.md Links the new crate’s changelog from the root changelog index.
Cargo.toml Adds seatbelt_http as a workspace dependency.
Cargo.lock Records the new workspace crate in the lockfile.
.spelling Adds 5xx to the spelling allowlist.
crates/seatbelt_http/Cargo.toml Defines the new crate (features, deps, docs.rs config, external-type allowlist).
crates/seatbelt_http/CHANGELOG.md Introduces the crate changelog with the initial release entry.
crates/seatbelt_http/README.md Adds the crate README (appears cargo-doc2readme generated) describing features/types.
crates/seatbelt_http/logo.png Adds crate logo asset (Git LFS).
crates/seatbelt_http/favicon.ico Adds crate favicon asset (Git LFS).
crates/seatbelt_http/src/lib.rs Crate root: feature-gated modules + shared public type exports.
crates/seatbelt_http/src/http_recovery.rs Implements HttpRecovery and shared recovery detection for HTTP results.
crates/seatbelt_http/src/http_clone.rs Implements HttpClone request cloning strategy and per-attempt routing support.
crates/seatbelt_http/src/retry.rs Provides HTTP-specialized retry aliases + extension trait methods and tests.
crates/seatbelt_http/src/timeout.rs Provides HTTP-specialized timeout aliases + extension trait for mapping timeout into HttpError.
crates/seatbelt_http/src/hedging.rs Provides HTTP-specialized hedging aliases + extension trait methods and tests.
crates/seatbelt_http/src/breaker.rs Provides HTTP-specialized breaker aliases + extension trait methods and origin-based breaker IDs.

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

Comment thread crates/seatbelt_http/src/breaker.rs Outdated
Copilot AI review requested due to automatic review settings May 19, 2026 11:27
Copy link
Copy Markdown
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

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Comment thread crates/seatbelt_http/src/breaker.rs
Comment thread crates/seatbelt_http/Cargo.toml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 13:27
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Comment thread crates/seatbelt_http/src/breaker.rs Outdated
Comment thread crates/seatbelt_http/src/http_clone.rs
Copilot AI review requested due to automatic review settings May 21, 2026 13:08
Copy link
Copy Markdown
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

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Comment thread crates/seatbelt_http/src/lib.rs
Comment thread crates/seatbelt_http/src/http_clone.rs
Copilot AI review requested due to automatic review settings May 22, 2026 13:14
@martintmk martintmk enabled auto-merge (squash) May 22, 2026 13:15
Copy link
Copy Markdown
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

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Comment thread crates/seatbelt_http/src/http_clone.rs
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.

5 participants