Expand description
(#6637) session.events: the socket transport’s live tail of one session,
standing in for the notification channel session.attach cannot have over
a one-frame-in, one-frame-out connection.
session.events — the streaming method a UDS client tails a session
through (#6637).
Why: session.attach is the one production handler that pushes on
crate::jsonrpc::ConnectionContext::notify, and a UDS connection served by
trusty_common::uds::server reads one request frame and writes one
response frame, so it is not a push channel. HTTP solved the same problem
with a dedicated SSE route (crate::serve::http::session_events_sse);
this is that route’s transport-native twin, registered with
trusty_common::uds::server::RpcRouter::typed_stream so the answer is a
sequence of frames instead of one.
What: open snapshots the session’s
ring buffer, then forwards the
daemon-global event bus filtered to that session, into the
trusty_common::uds::server::RpcStreamItems channel the router writes
frames from.
SessionEventsParams::after_seq
is what HTTP has no
equivalent of: a client whose connection was cut names the last seq it
confirmed, and the replay resumes above it instead of repeating the whole
ring. The subscribe happens BEFORE the replay snapshot so an event
published between the two is delivered rather than dropped, and every
forwarded envelope’s seq is compared against the highest already sent, so
the overlap that ordering creates never reaches the client twice.
A lagged bus ends the stream. The tokio::sync::broadcast bus drops
the oldest envelopes for a receiver that falls behind, so continuing would
deliver a tail with a hole in it that the client could not see. The stream
ends with an error frame instead; the client reconnects with after_seq
and the ring buffer refills the gap. session_events_sse skips a lag
silently, which is the behaviour this deliberately does not copy.
Test: events_stream_tests.
Structs§
- Session
Events Params session.events’ params.
Constants§
- METHOD
- The method name this stream is registered under.
Functions§
- open
- Open one
session.eventsstream.