Skip to main content

Module paced_channel

Module paced_channel 

Source
Expand description

Per-(channel, peer) outbound pacing wrapper.

Wraps a dyn Channel so consecutive send calls to the same recipient honour a configured floor on cadence. Drafts and progress updates are NOT paced — they are streaming UX events where slowing down would visibly degrade the live response. Only the final send (the wire- level outbound message) and finalize_draft enter the queue.

min_interval_secs == 0 returns the inner channel unchanged so the pacing path has zero overhead for the default config.

When the floor is active the wrapper holds a bounded FIFO queue per recipient. A send that arrives while the floor still has time left enqueues. A worker task drains the queue at the floor rate. When the queue is full the newest send is dropped and a WARN is emitted carrying enough attribution to diagnose the source without leaking message body. PACING_RECIPIENT_CAP bounds the number of distinct recipient rows retained via idle-state LRU eviction — only rows with no queued work and no running worker are eligible, so the cap is a target for idle state, not an unconditional hard bound on a pathological all-active burst.

Structs§

PacedChannel