pub enum Delivery {
Lossless,
LossyDropNewest,
}Expand description
Backpressure (delivery) policy for a single class of fast-lane events.
The event router forwards fast-lane frames (audio, text, transcripts, thoughts, VAD, phase) over a bounded channel to the fast-lane consumer. When that consumer falls behind and the channel fills, the policy decides what the router does — and crucially, whether the router blocks. Because the router is shared by both the fast lane and the control lane, a blocking fast-lane send stalls routing for all events, including control-lane lifecycle and tool events. The policy lets callers trade frame durability for router responsiveness on a per-class basis.
Variants§
Lossless
Never drop a frame: tx.send(ev).await — the router awaits when the
channel is full. This is the historical (and default) behavior and is
byte-for-byte identical to the pre-policy code path. Use it when every
frame matters and a slow consumer applying backpressure to the router is
acceptable.
LossyDropNewest
Drop the newest frame on overflow: tx.try_send(ev) and, on
TrySendError::Full,
discard the just-produced frame and bump a dropped-frame counter. The
router never blocks on this class, so a slow fast-lane consumer can no
longer stall control-lane routing. Use it for high-frequency, loss-
tolerant streams (e.g. partial transcripts, thoughts) where freshness of
already-queued frames matters less than keeping the router moving.
A drop-oldest / latest-only variant is intentionally not provided:
tokio’s mpsc has no clean “evict the oldest queued item” primitive, so
implementing it correctly would require a custom ring buffer. That is
left as future work rather than shipped half-working.