Skip to content

refactor(client): let the Streamer fill a store the caller opens - #2887

Merged
alpergundogdu merged 2 commits into
mainfrom
streamer-generic-store
Nov 12, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
streamer-generic-store

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Third step of moving the decdn gateway cache onto decdn-cache (#2881). The gateway will stream into a cache-backed store instead of a scratch .partial. To allow that, the Streamer now fills whatever store the caller opens.

What changes

  • StreamStore (doc-hidden): an IngestStore that also exposes present_grew(), the wakeup the reader waits on between checkpoints. ClientRangedStore implements it.
  • StreamStores (doc-hidden): opens the fill store for one stream from (hash, total_bytes). It is also implemented for &T, so one opener can serve many streams.
  • ScratchStores: the default opener. It does exactly what Streamer did before: a ClientRangedStore named by the hash in the scratch directory, opened off the runtime.
  • Streamer<'a, P, F, O = ScratchStores<'a>> gains with_stores(provider, funder, stores). VerifiedReader<S>, LiveReader<S> and StreamDrive<'a, S> gain a store parameter. Every new parameter defaults to the current type, so Streamer::new and every existing caller compile unchanged. crates/cli needs no edits.
  • The public_api snapshot is regenerated. The new generic parameters show up there, and existing source keeps compiling.

Tests

  • New a_stream_fills_the_store_its_stores_open: it streams a 1.5 MB blob through with_stores with a different store type that wraps ClientRangedStore. It checks that the output is byte-identical and that the opener ran once.
  • cargo nextest run -p decdn-client -p decdn-cli: pass.
  • INSTA_UPDATE=always cargo nextest run -p decdn-client --features public-api-test: snapshot regenerated, and it passes.
  • cargo clippy --workspace --all-targets --all-features with warnings denied, cargo doc --workspace --no-deps --document-private-items, check_crate_edges.py, cargo fmt --check: pass.

🤖 Generated with Claude Code

StreamStore is an IngestStore that also wakes the reader on each
checkpoint; StreamStores opens one per stream. Streamer::with_stores
takes the opener, and the reader and drive carry the store type. Every
new type parameter defaults to the scratch-directory ClientRangedStore,
so Streamer::new and its callers are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 01:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

The change still has an unresolved documentation inconsistency in crates/client/src/streamer.rs around whether multiple streams may share the same store instance, leaving the StreamStores contract unclear for implementers and callers.

1 open issue
What changed in this PR

Refactors decdn-client’s streaming path so Streamer fills a caller-opened store (instead of always creating a scratch-backed store), enabling downstream components like the gateway cache to stream directly into a cache-backed store.

Changes:

  • Introduces doc-hidden StreamStore/StreamStores abstractions and a default ScratchStores opener that preserves prior behavior.
  • Makes Streamer, StreamDrive, LiveReader, and VerifiedReader generic over the store type while keeping existing callers source-compatible via defaults.
  • Adds a test for with_stores and regenerates the public_api snapshot to reflect the new generic parameters and exports.
File Description
crates/​client/​tests/​snapshots/​public_api__public_api.snap Regenerates the public API snapshot to reflect the new store-generic streamer types and re-exports.
crates/​client/​src/​streamer/​tests.rs Adds a regression test ensuring Streamer::with_stores streams into a caller-provided store and only opens it once.
crates/​client/​src/​streamer.rs Introduces store/opener traits and threads a caller-opened fill store through the streaming pipeline with a scratch-backed default implementation.
crates/​client/​src/​lib.rs Updates the crate root exports to expose the new store-related types alongside the streamer API.

Review effort: Balanced

Comment thread crates/client/src/streamer.rs Resolved
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 5dd72da streamer-generic-sto... 991ab00 +/-
77% 77% 0%
View coverage of the 3 most impacted files.
File main 5dd72da streamer-generic-sto... 991ab00 +/-
crates/client/src/lib.rs 90% 89% -1%
crates/node/src/dht/publish.rs 77% 78% +1%
crates/client/src/streamer.rs 88% 89% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@alpergundogdu
alpergundogdu merged commit f238ccf into main Nov 12, 2026
37 checks passed
@alpergundogdu
alpergundogdu deleted the streamer-generic-store branch November 12, 2026 01:45
alpergundogdu added a commit that referenced this pull request Nov 12, 2026
Resolve the Streamer store refactor (#2887) against the proven-size
acquire: the stream store opens at the proven size with no cap clamp, and
the streamer tests keep the caller-supplied store test. Seed e2e origins
with their .sizeproof sibling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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