Skip to main content

resubscribing_stream

Function resubscribing_stream 

Source
pub fn resubscribing_stream<T, F, Fut>(
    signals: Arc<ConnectionSignals>,
    channel_size: usize,
    subject: &'static str,
    initial: Pin<Box<dyn Stream<Item = T> + Send>>,
    make_stream: F,
) -> impl Stream<Item = T> + Send + 'static
where T: Send + 'static, F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Pin<Box<dyn Stream<Item = T> + Send>>, Error>> + Send,
Expand description

Spawns the background re-subscribe/forward task for a durable consumer and returns the consumer-facing stream.

initial is the already-created message stream (so setup errors surface synchronously at the call site); make_stream re-creates it after each disconnect. Items are forwarded through an internal channel holding channel_size items, and the task re-subscribes with exponential backoff until the receiver is dropped.

Shared by Subscriber::subscribe and Responder::respond, which differ only in the per-message stream make_stream produces.