Skip to main content

spawn_encoded_event_stream

Function spawn_encoded_event_stream 

Source
pub fn spawn_encoded_event_stream(
    subscription: EventSubscription,
    gate: NamespaceEventGate,
    outbound_buffer_bound: usize,
) -> Result<EncodedEventStream, ServerError>
Expand description

Spawn the non-blocking engine-reader side of a WebSocket subscription.

Replay frames (the resume history slice) are queued with awaiting sends so a replay longer than the per-connection buffer is delivered completely โ€” replay can never be silently dropped or spuriously lagged. The live tail keeps try_send: the reader never awaits socket capacity for live events, so a slow consumer lags out (one terminal frame) instead of back-pressuring the engine event tail.

Every event โ€” replay and live, all subscription kinds โ€” passes the namespace gate and the subscription selector before its frame is encoded, and per-workflow streams carry a delivered-sequence contiguity tripwire.

ยงErrors

Returns ServerError::Config if outbound_buffer_bound is zero.