Skip to content
Merged
5 changes: 5 additions & 0 deletions quest/m1/track-priority-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Direction to settle in the draft first, then the code:
presents send order as unrelated.
- A per-session cap on distinct ranks is a scheduling detail; whatever replaces
the 255-entry sort must stay O(log n) per group under chat-shaped churn.
- moq-quic already has the fair tier: send domains sharing bytes by deficit
round robin, with groups inside them. They are crate-private (exercised only
by its tests) until this quest gives them a consumer. Exposing them also
gives moq-net's `poll::Session::send_group(priority)` a domain, so land that
in the same trait break and implementers break once.

Signed priority, decided with the maintainer:

Expand Down
19 changes: 19 additions & 0 deletions quest/m2/drop-web-transport-trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ layer instead of reopening it.
- Report the public API impact per crate: deleted generic `Session<S>`
adapters, and new impls on concrete session types.

The two native QUIC stacks drifted apart behind the adapters. Align them while
each gets its own impl:

- moq-tokio's `quic::web::Session` derefs to `quic::driver::Connection`, so it
has two `send_datagram`s with different framing: its own prefixes the
WebTransport session id, the driver's reached through `Deref` does not.
Prefer dropping the `Deref` over documenting the trap.
- The driver stream setters disagree: moq-tokio's `set_priority`/`set_group`
take `&self` and return `Result<(), ClosedStream>`, moq-uring's take
`&mut self` and return nothing.
- The sealed `Grouped::send_group` takes `&self` in moq-tokio and `&mut self`
in moq-uring, and only moq-tokio requires `GroupedSend::Group: Send + Sync`.
- moq-uring's driver opens streams only through `web_transport_trait`, so
`SendOptions` reach a new stream through its setters in both runtimes'
adapters. A native impl can pass them to the open, as moq-tokio's driver
`open_uni`/`open_bi` already accept.
- moq-tokio's `quic::driver` and `quic::web` modules are public but
`#[doc(hidden)]`. Decide whether they are API or should be private.

Notes from related quests:
- [qmux on moq-quic](/quest/m2/quic-qmux.md) planned to port qmux's
`web-transport-trait` impl. If it lands first, its impl targets moq-net's
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-cli/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ How to update your invocation and config for each breaking change, newest first.

## Unreleased

### A fixed `--connect-bind` refuses a WAN cluster (#5674)

`--connect` and `--cluster-connect` or `--cluster-connect-api` used to share one client; now each binds its own, so a fixed `--connect-bind` port with both stops startup.
Use port 0, or drop `--connect`.

### `moq export ts --delay` defaults to 1 s and includes the send-ahead (#5553)

The output trails a TS source by the delay instead of twice it.
Expand Down
33 changes: 25 additions & 8 deletions rs/moq-ffi/src/transport/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,30 @@ impl<S: backend::Session<SendStream: 'static, RecvStream: 'static> + Clone + 'st
.map_err(Error)
.map(|res| res.map(|(send, recv)| (SendStream(send), RecvStream(recv))))
}
fn poll_open_uni(&mut self, cx: &mut Context<'_>) -> Poll<Result<Self::SendStream, Self::Error>> {
fn poll_open_uni(
&mut self,
cx: &mut Context<'_>,
options: poll::SendOptions<'_, poll::Ungrouped>,
) -> Poll<Result<Self::SendStream, Self::Error>> {
backend::Session::poll_open_uni(&mut self.0, cx)
.map_err(Error)
.map(|res| res.map(SendStream))
.map(|res| res.map(|send| SendStream(send).scheduled(options)))
}
fn poll_open_bi(&mut self, cx: &mut Context<'_>) -> Poll<Result<poll::BiStreams<Self>, Self::Error>> {
fn poll_open_bi(
&mut self,
cx: &mut Context<'_>,
options: poll::SendOptions<'_, poll::Ungrouped>,
) -> Poll<Result<poll::BiStreams<Self>, Self::Error>> {
backend::Session::poll_open_bi(&mut self.0, cx)
.map_err(Error)
.map(|res| res.map(|(send, recv)| (SendStream(send), RecvStream(recv))))
.map(|res| res.map(|(send, recv)| (SendStream(send).scheduled(options), RecvStream(recv))))
}
fn send_group(&mut self, _: i64) -> Option<poll::Ungrouped> {
None
}
/// The backend cannot rank a datagram against a stream, so the group and order are ignored,
/// and a datagram it has no room for is dropped.
fn send_datagram(&mut self, payload: Bytes, _: Option<&poll::Ungrouped>, _: i64) -> Result<(), Self::Error> {
/// The backend cannot rank a datagram against a stream, so `options` are ignored, and a
/// datagram it has no room for is dropped.
fn send_datagram(&mut self, payload: Bytes, _: poll::SendOptions<'_, poll::Ungrouped>) -> Result<(), Self::Error> {
let mut cx = Context::from_waker(std::task::Waker::noop());
match backend::Session::poll_send_datagram(&mut self.0, &mut cx, &payload) {
Poll::Ready(res) => res.map_err(Error),
Expand Down Expand Up @@ -113,6 +121,13 @@ impl<S: backend::Session<SendStream: 'static, RecvStream: 'static> + Clone + 'st
}
/// An outgoing WebTransport stream adapted to moq-net.
pub struct SendStream<S>(S);
impl<S: backend::SendStream + 'static> SendStream<S> {
/// Schedule a newly opened stream, which has no group to join.
fn scheduled(mut self, options: poll::SendOptions<'_, poll::Ungrouped>) -> Self {
poll::SendStream::set_priority(&mut self, options.priority);
self
}
}
impl<S: backend::SendStream + 'static> poll::SendStream for SendStream<S> {
type Error = Error<S::Error>;
type Group = poll::Ungrouped;
Expand Down Expand Up @@ -293,7 +308,9 @@ mod tests {
poll::Session::stats(&session).rtt(),
Some(std::time::Duration::from_millis(7))
);
let Poll::Ready(Ok((mut send, mut recv))) = poll::Session::poll_open_bi(&mut session, &mut cx) else {
let Poll::Ready(Ok((mut send, mut recv))) =
poll::Session::poll_open_bi(&mut session, &mut cx, Default::default())
else {
panic!("open failed")
};
let mut buf = Bytes::from_static(b"abcd");
Expand Down
15 changes: 11 additions & 4 deletions rs/moq-net/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,24 @@ producer.finish().wait().await;
Rename `auth::Token` to `auth::Auth`.
`auth::Handle::add` returns an `auth::Auth`, which is `Clone` and compares by identity, so a route can name it with `origin::Route::with_auth`.

### Custom transports send datagrams without polling (#5770)
### Custom transports open and send with `SendOptions` (#5770, #5872)

`transport::poll::Session::send_datagram` replaces `poll_send_datagram`.
It takes the payload as `Bytes`, the send group to schedule it in (`None` for ungrouped), and an order, and never blocks.
It takes the payload as `Bytes` and a `SendOptions { group, priority }`, and never blocks.
`poll_open_uni` and `poll_open_bi` take the `SendOptions` the new stream starts with, as do the `open_uni` and `open_bi` helpers.
`SendOptions::default()` is ungrouped at priority 0.

```rust
fn poll_open_uni(
&mut self,
cx: &mut Context<'_>,
options: SendOptions<'_, <Self::SendStream as SendStream>::Group>,
) -> Poll<Result<Self::SendStream, Self::Error>> { ... }

fn send_datagram(
&mut self,
payload: Bytes,
group: Option<&<Self::SendStream as SendStream>::Group>,
order: i64,
options: SendOptions<'_, <Self::SendStream as SendStream>::Group>,
) -> Result<(), Self::Error> { ... }
```

Expand Down
26 changes: 17 additions & 9 deletions rs/moq-net/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,16 @@ mod tests {
fn poll_open_bi(
&mut self,
_cx: &mut Context<'_>,
_: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Poll<Result<(Self::SendStream, Self::RecvStream), Self::Error>> {
Poll::Ready(self.state.control_stream.lock().unwrap().take().ok_or(FakeError))
}

fn poll_open_uni(&mut self, _cx: &mut Context<'_>) -> Poll<Result<Self::SendStream, Self::Error>> {
fn poll_open_uni(
&mut self,
_cx: &mut Context<'_>,
_: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Poll<Result<Self::SendStream, Self::Error>> {
Poll::Pending
}

Expand All @@ -634,8 +639,7 @@ mod tests {
fn send_datagram(
&mut self,
_: Bytes,
_: Option<&crate::transport::poll::Ungrouped>,
_: i64,
_: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Result<(), Self::Error> {
Ok(())
}
Expand Down Expand Up @@ -1005,8 +1009,9 @@ mod tests {
fn poll_open_bi(
&mut self,
cx: &mut Context<'_>,
options: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Poll<Result<(Self::SendStream, Self::RecvStream), Self::Error>> {
self.inner.poll_open_bi(cx).map_ok(|(send, recv)| {
self.inner.poll_open_bi(cx, options).map_ok(|(send, recv)| {
(
LocalSend {
inner: send,
Expand All @@ -1020,8 +1025,12 @@ mod tests {
})
}

fn poll_open_uni(&mut self, cx: &mut Context<'_>) -> Poll<Result<Self::SendStream, Self::Error>> {
self.inner.poll_open_uni(cx).map_ok(|stream| LocalSend {
fn poll_open_uni(
&mut self,
cx: &mut Context<'_>,
options: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Poll<Result<Self::SendStream, Self::Error>> {
self.inner.poll_open_uni(cx, options).map_ok(|stream| LocalSend {
inner: stream,
_local: self._local.clone(),
})
Expand All @@ -1034,10 +1043,9 @@ mod tests {
fn send_datagram(
&mut self,
payload: Bytes,
group: Option<&crate::transport::poll::Ungrouped>,
order: i64,
options: crate::transport::poll::SendOptions<'_, crate::transport::poll::Ungrouped>,
) -> Result<(), Self::Error> {
self.inner.send_datagram(payload, group, order)
self.inner.send_datagram(payload, options)
}

fn poll_recv_datagram(&mut self, cx: &mut Context<'_>) -> Poll<Result<Bytes, Self::Error>> {
Expand Down
8 changes: 6 additions & 2 deletions rs/moq-net/src/coding/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ impl<S: crate::transport::poll::Session, V: StreamCodes> Stream<S, V> {
where
V: Clone,
{
let (send, recv) = ready!(session.poll_open_bi(cx)).map_err(|err| version.transport_error(err))?;
let (send, recv) =
ready!(session.poll_open_bi(cx, Default::default())).map_err(|err| version.transport_error(err))?;
Poll::Ready(Ok(Self::build(send, recv, version)))
}

Expand All @@ -40,7 +41,10 @@ impl<S: crate::transport::poll::Session, V: StreamCodes> Stream<S, V> {
where
V: Clone,
{
let (send, recv) = session.open_bi().await.map_err(|err| version.transport_error(err))?;
let (send, recv) = session
.open_bi(Default::default())
.await
.map_err(|err| version.transport_error(err))?;
Ok(Self::build(send, recv, version))
}

Expand Down
5 changes: 0 additions & 5 deletions rs/moq-net/src/coding/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ impl<S: crate::transport::poll::SendStream, V: StreamCodes> Writer<S, V> {
self.stream.as_mut().unwrap().set_priority(priority);
}

/// Move the stream into a send group from its session.
pub fn set_group(&mut self, group: &S::Group) {
self.stream.as_mut().unwrap().set_group(group);
}

/// Cast the writer to a different version, used during version negotiation.
pub fn with_version<O>(mut self, version: O) -> Writer<S, O> {
Writer {
Expand Down
31 changes: 23 additions & 8 deletions rs/moq-net/src/ietf/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,11 @@ impl<S: crate::transport::poll::Session> ControlStreamAdapter<S> {
/// Open a real (non-virtual) bidi stream, bypassing control stream multiplexing.
/// Used for v16 SubscribeNamespace which moved to its own bidi stream.
pub async fn open_native_bi(&mut self) -> Result<(AdapterSend<S>, AdapterRecv<S>), crate::Error> {
let (send, recv) = self.inner.open_bi().await.map_err(|_| crate::Error::Closed)?;
let (send, recv) = self
.inner
.open_bi(Default::default())
.await
.map_err(|_| crate::Error::Closed)?;
Ok((AdapterSend::Real(send), AdapterRecv::Real(recv)))
}

Expand Down Expand Up @@ -1193,14 +1197,23 @@ impl<S: crate::transport::poll::Session> crate::transport::poll::Session for Con
fn poll_open_bi(
&mut self,
_cx: &mut Context<'_>,
// Rides the control stream, which no group schedules.
_: crate::transport::poll::SendOptions<'_, <Self::SendStream as crate::transport::poll::SendStream>::Group>,
) -> Poll<Result<(Self::SendStream, Self::RecvStream), Self::Error>> {
let (send, recv) = self.shared.open_outgoing(self.version);
Poll::Ready(Ok((AdapterSend::Virtual(send), AdapterRecv::Virtual(recv))))
}

fn poll_open_uni(&mut self, cx: &mut Context<'_>) -> Poll<Result<Self::SendStream, Self::Error>> {
fn poll_open_uni(
&mut self,
cx: &mut Context<'_>,
options: crate::transport::poll::SendOptions<
'_,
<Self::SendStream as crate::transport::poll::SendStream>::Group,
>,
) -> Poll<Result<Self::SendStream, Self::Error>> {
self.inner
.poll_open_uni(cx)
.poll_open_uni(cx, options)
.map(|r| r.map(AdapterSend::Real).map_err(|_| crate::Error::Closed))
}

Expand All @@ -1217,11 +1230,13 @@ impl<S: crate::transport::poll::Session> crate::transport::poll::Session for Con
fn send_datagram(
&mut self,
payload: Bytes,
group: Option<&<Self::SendStream as crate::transport::poll::SendStream>::Group>,
order: i64,
options: crate::transport::poll::SendOptions<
'_,
<Self::SendStream as crate::transport::poll::SendStream>::Group,
>,
) -> Result<(), Self::Error> {
self.inner
.send_datagram(payload, group, order)
.send_datagram(payload, options)
.map_err(|_| crate::Error::Closed)
}

Expand Down Expand Up @@ -1914,7 +1929,7 @@ mod tests {
}
script.extend_from_slice(then);
let mut session = ScriptedSession::new(script);
let (_, recv) = session.open_bi().await.unwrap();
let (_, recv) = session.open_bi(Default::default()).await.unwrap();
// We are the server, so the client's request IDs are even.
let control = Control::new(None, false).with_window(window, false, VERSION);
let adapter = ControlStreamAdapter::new(session, control, VERSION);
Expand Down Expand Up @@ -1979,7 +1994,7 @@ mod tests {
};
let script = encode_raw(ietf::SubscribeUpdate::ID, &Bytes::copy_from_slice(body), version);
let mut session = ScriptedSession::new(script.to_vec());
let (_, recv) = session.open_bi().await.unwrap();
let (_, recv) = session.open_bi(Default::default()).await.unwrap();
let adapter = ControlStreamAdapter::new(session, Control::new(None, false), version);
let log = Log::default();
let writer = Writer::new(SinkSend::new(log.clone()), version);
Expand Down
Loading
Loading