Skip to content

Keep owned builders while making async setup futures Send - #320

Closed
alexliesenfeld wants to merge 5 commits into
masterfrom
codex/257-owned-builders-send
Closed

alexliesenfeld wants to merge 5 commits into
masterfrom
codex/257-owned-builders-send

Conversation

@alexliesenfeld

@alexliesenfeld alexliesenfeld commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Superseded by #325, using the renamed owned-builders-send branch and including #322. This PR was closed automatically by GitHub when its source branch was renamed. The original description and discussion are preserved below.


Follow-up to #257, targeting its breakage_mut_ref branch.

Keep async registration usable inside tokio::spawn while retaining the existing owned builder API. Helpers such as fn with_path(when: When, path: &str) -> When, structs storing builders, immediate 'static callbacks, Any integrations, staged forwarding/proxy filters, and shared recording configuration continue to work without lifetime changes.

The Rc<Cell<_>> handles now live in a synchronous block that produces an owned configuration before the first .await. This covers mock, forwarding, proxy and recording setup. Unwind guards preserve configured values when a setter panic is caught, including a recording filter's nested configuration.

The tradeoff is that the builders themselves remain !Send/!Sync and retain their existing allocations and reference counting. Setup futures are Send when their inputs permit it; no extra public Send bounds are added.

Validation:

  • Nine new regression tests pass, including actual requests, tokio::spawn, owned helper composition, staged filters and caught panics.
  • All 142 library unit tests, 150 integration tests and 136 doctests pass; four existing integration tests are ignored.
  • Tokio/Actix/smol compatibility test passes.
  • Removing either restoration guard in an isolated temporary copy makes its panic regression test fail with the expected lost body or matcher state.
  • The new tests pass with no default features, proxy alone, and record alone.
  • All 44 pairwise feature checks without dev dependencies pass.
  • Formatting and whitespace checks pass.
  • All-target/all-feature Clippy passes with clippy::let_and_return allowed. The unchanged Replace Rc<Cell> builders with mutable references #257 head fails that same lint in src/server/tls.rs; this patch leaves that unrelated code alone.

FalkWoldmann and others added 5 commits September 27, 2026 22:24
Refactor `When` and rule builder APIs to mutate configs in place via
`&mut` references, removing `Rc<Cell>` plumbing across proxy/server
setup paths and deleting the now-unused `update_cell` helper.
@FalkWoldmann
FalkWoldmann changed the base branch from breakage_mut_ref to master October 4, 2026 08:38
@alexliesenfeld
alexliesenfeld deleted the codex/257-owned-builders-send branch October 4, 2026 12:42
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.

2 participants