refactor(plus): extract Litestream into a shared bencher_litestream crate#901
refactor(plus): extract Litestream into a shared bencher_litestream crate#901epompeii wants to merge 2 commits into
Conversation
🤖 Claude Code ReviewPR: #901 Code Review: Extract Litestream into shared
|
91aca73 to
a268bc6
Compare
|
| Branch | u/ep/bencher-litestream |
| Testbed | intel-v1 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| Adapter::Json | 📈 view plot 🚷 view threshold | 4.69 µs(+2.24%)Baseline: 4.59 µs | 4.84 µs (97.01%) |
| Adapter::Magic (JSON) | 📈 view plot 🚷 view threshold | 4.56 µs(+2.04%)Baseline: 4.47 µs | 4.69 µs (97.26%) |
| Adapter::Magic (Rust) | 📈 view plot 🚷 view threshold | 25.50 µs(+0.16%)Baseline: 25.45 µs | 26.44 µs (96.42%) |
| Adapter::Rust | 📈 view plot 🚷 view threshold | 3.51 µs(+0.99%)Baseline: 3.47 µs | 3.59 µs (97.68%) |
| Adapter::RustBench | 📈 view plot 🚷 view threshold | 3.51 µs(+1.15%)Baseline: 3.47 µs | 3.58 µs (98.00%) |
6361e77 to
b318ee5
Compare
…rate Move the Litestream config types, YAML rendering, restore/replicate runtime, and the autocheckpoint PRAGMA out of bencher_json and the API server into a new Bencher Plus crate, plus/bencher_litestream, so the code can be shared by path with other consumers. - bencher_json re-exports the config types from the new crate at their existing paths and keeps the From<LogLevel> conversion, so the public API and the OpenAPI schema are unchanged. - services/api calls bencher_litestream::run_litestream, computing the database path, config path, and log level at the call site. - bencher_config uses bencher_litestream::DISABLE_AUTOCHECKPOINT_PRAGMA. The crate is feature-gated so config-only consumers stay light: the bencher_valid backend is selected via server/client features (threaded from bencher_json, not hardcoded), and yaml/runtime/schema are opt-in. The moved unit tests pass and cargo gen-spec / gen-ts produce no diff.
b318ee5 to
3a027aa
Compare
bencher_adapter hardcoded bencher_json = { features = ["server"] }, which
forced the server bencher_valid backend (regex, sha2, hex, rand) into
every consumer via feature unification, including the client-side CLI
(which links bencher_adapter only for `bencher mock`).
Replace the hardcoded backend with server/client features that thread
bencher_json's choice, mirroring bencher_boundary. Consumers select the
backend through their own bencher_json dependency: the CLI and
bencher_noise resolve to client, the server crates to server. The
standalone bencher_adapter bench build selects server explicitly.
The CLI's bencher_valid now compiles with client only (regex-lite); the
server backend no longer ships in the CLI binary.
What
Extracts the Litestream integration into a new Bencher Plus crate,
plus/bencher_litestream, shared by the API server (and, next, an external consumer by path). The code is moved, not rewritten, so behavior and the OpenAPI schema are unchanged.Today the Litestream code lives in three places:
bencher_json(system/config/plus/litestream.rs)services/api/src/main.rs(run_litestream,LitestreamError)bencher_config(config_tx.rs)This PR consolidates all three into one crate.
The crate
bencher_litestreamis feature-gated so config-only consumers stay light:default: config types (JsonLitestream,JsonReplica, ...) +Sanitizeschema:JsonSchemaderives for the OpenAPI specyaml:into_yamlrenderingruntime:run_litestreamrestore-then-replicate supervision (impliesyaml)It also exposes
DISABLE_AUTOCHECKPOINT_PRAGMAandLitestreamLevel(withFrom<LogLevel>kept inbencher_json).Consumers
bencher_jsonre-exports the config types at their existing paths, sobencher_json::system::config::JsonLitestreamstill resolves and the schema is unchanged.services/apicallsbencher_litestream::run_litestream, computing the database path, config path, and log level at the call site.bencher_configusesbencher_litestream::DISABLE_AUTOCHECKPOINT_PRAGMA.Notes
run_litestreamnow takes its inputs directly (db_path,config_path: Utf8PathBuf,log_level: LitestreamLevel) instead of&Config. A newLitestreamError::DatabasePathNotUtf8variant covers the call-site path conversion.plus/**.Verification
cargo gen-specandcargo gen-tsproduce no diff (schema neutral).cargo clippy --no-deps --all-targets --all-features -- -Dwarningsclean.cargo nextest run --all-features(the moved unit tests pass) andcargo test --docgreen.cargo check --no-default-featurescompiles.Not covered by CI: a live restore/replicate smoke test against an S3/R2 bucket.