moq-lite-05: implement FETCH for past groups via TrackConsumer::fetch#1601
Open
kixelated wants to merge 2 commits into
Open
moq-lite-05: implement FETCH for past groups via TrackConsumer::fetch#1601kixelated wants to merge 2 commits into
kixelated wants to merge 2 commits into
Conversation
Add a one-shot `TrackConsumer::fetch(group, options) -> GroupConsumer` that retrieves a single past group without holding a subscription. A cached group is returned directly; otherwise the request bridges to a wire moq-lite FETCH, blocking on a new FETCH_OK (mirroring SUBSCRIBE/SUBSCRIBE_OK). - model: a dynamic group-request channel parallel to dynamic track requests (request_fetch / FetchPending / BroadcastDynamic::requested_group / GroupRequest). Cache hit returns the group; an aborted cached group is bypassed. - wire: new FetchOk message; Fetch.frame_start (lite-05+); the publisher honors frame_start by skipping earlier frames. - publisher: recv_fetch / run_fetch serve the group's frames on the fetch stream. - subscriber: serve group requests by issuing FETCH upstream and routing frames into the producer that resolves the fetcher. - relay web.rs: /fetch?group=N uses fetch() instead of subscribe(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…y-colden-96e186 # Conflicts: # rs/moq-net/src/lite/fetch.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements a one-shot fetch on
TrackConsumer, so you can retrieve a single past group without holding a live subscription:If the group is already cached it's returned directly; otherwise the request bridges to a wire moq-lite
FETCH, blocking on a newFETCH_OK(mirroring howsubscribeblocks onSUBSCRIBE_OK). TheFETCHwas previously a wire-only definition the publisher rejected withUnexpectedStream.Why
The only way to read a group was to
subscribeto a track and walk its cache. There was no first-class way to grab one past group.fetchlives onTrackConsumer(not a live subscription) on purpose: you no longer have to subscribe just to fetch.How it works
The model→wire bridge reuses the existing dynamic track-request machinery, but for a single group:
The FETCH response streams on the same bidirectional control stream as the request (like IETF MoQT): the subscriber writes
Fetch; the publisher repliesFetchOkthen streams the group's frames; stream FIN ends the group. Errors propagate via stream reset.Changes
model/broadcast.rs):Fetchoptions struct, a dynamic group-request channel (request_fetch/FetchPending/GroupRequest/BroadcastDynamic::requested_group), andTrackConsumer::fetch.GroupConsumer::timescale()accessor (model/group.rs).lite/fetch.rs): newFetchOk(group echo + compression + timescale);Fetch.frame_start(lite-05+). The publisher honorsframe_startby skipping earlier frames.lite/publisher.rs):recv_fetch/run_fetchserve the group's frames on the fetch stream (gated to lite-05+).lite/subscriber.rs): serve group requests by issuingFETCHupstream and routing frames into the producer that resolves the fetcher.moq-relay/src/web.rs):GET /fetch/<broadcast>/<track>?group=Nusesfetch()instead ofsubscribe().?group=latestkeeps the subscribe path (fetch needs a concrete group).Out of scope (follow-ups)
frame_startresume reseed. The publisher honorsframe_starton the wire, butfetch()always requests0; an aborted cached group is bypassed with a full re-fetch. True resume (requestframe_start = N, stitch onto the N cached frames) needs aGroupProducerthat begins at a logical frame offset — a separate model change.FetchOk.compression = None); the modelGroupConsumercarries no per-track compress hint.rs/moq-netwire/API withjs/net(which already has alite/fetch.tsstub) anddoc/concept. Deferred to a follow-up.Built on #1595
#1595 (now merged into
dev) added theFetch.frame_startwire field.devhas been merged in and thefetch.rsoverlap reconciled: this PR keeps #1595's field + tests and addsFetchOkplus the serving logic that actually usesframe_start.Test plan
cargo test -p moq-net— wire roundtrip (FetchOk,frame_startgating) + 9 model unit tests (cache hit, miss-queues-request, past-final NotFound, aborted-cache bypass, coalescing, no-dynamic NotFound, deny, drop-cancels, dynamic-drop-aborts).cargo test -p moq-native --test broadcast— newbroadcast_moq_lite_05_fetch_webtransportend-to-end fetch over a real session (WebTransport; Lite05Wip isn't ALPN-advertised so raw QUIC is excluded, matching the other Lite05 tests).cargo test -p moq-relay,cargo clippy --workspace --all-targets,cargo fmt --check.Targets
devper branch targeting (wire-protocol change underrs/moq-net).🤖 Generated with Claude Code
(Written by Claude)