Skip to content

refactor!: simplify replay API — remove MatchStrategy, ReplaySource & Snapshots - #7

Merged
JosiahBull merged 2 commits into
mainfrom
jo/remove-match-strategy
Jun 16, 2026
Merged

refactor!: simplify replay API — remove MatchStrategy, ReplaySource & Snapshots#7
JosiahBull merged 2 commits into
mainfrom
jo/remove-match-strategy

Conversation

@JosiahBull

@JosiahBull JosiahBull commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two related simplifications of the replay/storage public API (bumps 0.4.0 → 0.5.0, one minor bump covering both breaking changes).

1. Remove MatchStrategy (commit bc0d76f)

The Custom matcher was never needed — replay only ever uses MethodUriAndBodyHash. Matching is now fixed to a single key: (method, origin-form URI [path + query], SHA-256 of body).

  • Removed the MatchStrategy enum and CustomMatcher type alias.
  • Dropped the strategy parameter from the replay constructors.
  • lookup() collapses to the single hash-indexed path (no per-call match, no linear-scan branch).

2. Remove ReplaySource / Snapshots from the public API (commit 729f34b)

Replay is now configured purely by attaching a SnapshotStorage backend to an upstream — no caller-facing replay type.

  • ReplaySource is now pub(crate), built internally from the backend's load() stream at run(); Snapshots is deleted.
  • add_upstream_with / add_upstream_with_mode take Option<SharedStorage> directly.
  • Added InMemoryStorage — a real in-memory SnapshotStorage in partly-proxy-types (promotes the former storage.rs doc example) — for filesystem-free replay/fixtures, replacing Snapshots::in_memory.
  • Dropped the now-unused ReplaySource::from_jsonl.

Migration

// before
let replay = ReplaySource::from_jsonl(path, MatchStrategy::MethodUriAndBodyHash)?;
.add_upstream_with("api", cfg, mw, Some(Snapshots::from_storage(store, strategy)))

// after — construct a backend, attach it
let store: SharedStorage = Arc::new(JsonlStorage::open(path).await?);
.add_upstream_with("api", cfg, mw, Some(store))

// replay-only fixture (was Snapshots::in_memory)
let store: SharedStorage = Arc::new(InMemoryStorage::from(exchanges));
.add_upstream_with("api", cfg, mw, Some(store))

Versioning

0.5.0. Both commits are breaking; under the repo's pre-1.0 rule (minor = breaking boundary) one minor bump from main's 0.4.0 covers them and clears the cargo semver-checks gate (baseline = PR base = main).

Docs

SPECIFICATION.md §2/§3.3/§4/§4.1/§5/§8/§8.1/§8.1.1/§9.1/§20.1 rewritten for the fixed match key and the storage-backend attach model (also cleared leftover strategy args from the §4/§20.1 examples).

Testing

  • cargo build --workspace --all-targets — clean
  • cargo test --workspace — all 23 test binaries pass
  • cargo clippy --workspace --all-targets — clean
  • cargo fmt --check --all — clean

The Custom match strategy was never needed — replay only ever uses
MethodUriAndBodyHash. Remove the MatchStrategy enum and CustomMatcher
type alias, drop the strategy parameter from ReplaySource::{new,
from_jsonl,from_storage} and Snapshots::{from_storage,in_memory}, and
collapse the lookup to the single hash-indexed path (no more per-call
match on strategy, no linear-scan branch).

Breaking change: bump 0.4.0 -> 0.5.0 (pre-1.0 minor = breaking boundary).

Spec §2/§5/§8.1/§8.1.1 updated to describe the fixed match key instead
of pluggable strategies.
Replay is now configured purely by attaching a SnapshotStorage backend
to an upstream — there is no caller-facing replay type.

- `ReplaySource` and `Snapshots` are removed from the public API
  (`ReplaySource` is now `pub(crate)`, built internally from the attached
  backend's `load()` stream at `run()`; `Snapshots` is deleted).
- `add_upstream_with` / `add_upstream_with_mode` take `Option<SharedStorage>`
  directly instead of `Option<Snapshots>`.
- Add `InMemoryStorage`, a real in-memory `SnapshotStorage` backend in
  partly-proxy-types (promotes the former storage.rs doc example), for
  filesystem-free replay/fixtures — replaces `Snapshots::in_memory`.
- Drop the now-unused `ReplaySource::from_jsonl`; the round-trip test
  loads via `from_storage` instead.

No version bump: 0.5.0 already covers these breaking changes vs main's
0.4.0 baseline.

Spec §3.3/§4/§4.1/§8/§9.1/§20.1 updated to the storage-backend attach
model (also clears leftover `strategy` args from the §4/§20.1 examples).
@JosiahBull JosiahBull changed the title refactor!: remove MatchStrategy, always match by method+uri+body-hash refactor!: simplify replay API — remove MatchStrategy, ReplaySource & Snapshots Jun 16, 2026
@JosiahBull
JosiahBull merged commit 7e62d42 into main Jun 16, 2026
3 checks passed
@JosiahBull
JosiahBull deleted the jo/remove-match-strategy branch June 16, 2026 04:51
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