pub struct BroadcastOutputStream<D = LossyWithoutBackpressure, R = NoReplay>{ /* private fields */ }Expand description
The output stream from a process using a multi-consumer broadcast backend.
Broadcast streams support multiple consumers and can optionally retain replay history for consumers that attach after output has already arrived. Use this backend when the same stream needs concurrent fanout, such as logging plus readiness checks or logging plus collection. Delivery policy still determines whether slow active consumers observe gaps or apply backpressure.
Implementations§
Source§impl<D> BroadcastOutputStream<D, ReplayEnabled>where
D: Delivery,
impl<D> BroadcastOutputStream<D, ReplayEnabled>where
D: Delivery,
Sourcepub fn seal_replay(&self)
pub fn seal_replay(&self)
Seals replay history for future subscribers.
This is a one-way, idempotent operation. Active subscribers keep their unread tail data according to the configured delivery policy.
§Panics
Panics if the internal state mutex is poisoned.
Sourcepub fn is_replay_sealed(&self) -> bool
pub fn is_replay_sealed(&self) -> bool
Returns true once replay history has been sealed.
§Panics
Panics if the internal state mutex is poisoned.
Source§impl<D, R> BroadcastOutputStream<D, R>
impl<D, R> BroadcastOutputStream<D, R>
Sourcepub fn wait_for_line(
&self,
timeout: Duration,
predicate: impl Fn(Cow<'_, str>) -> bool + Send + 'static,
options: LineParsingOptions,
) -> impl Future<Output = Result<WaitForLineResult, StreamReadError>> + Send + 'static
pub fn wait_for_line( &self, timeout: Duration, predicate: impl Fn(Cow<'_, str>) -> bool + Send + 'static, options: LineParsingOptions, ) -> impl Future<Output = Result<WaitForLineResult, StreamReadError>> + Send + 'static
Waits for a line that matches the given predicate within timeout.
The returned future resolves to
Ok(WaitForLineResult::Matched) if a matching line is found,
Ok(WaitForLineResult::StreamClosed) if the stream ends first, or
Ok(WaitForLineResult::Timeout) if the timeout expires first.
The stream subscription is acquired synchronously inside this method, before the
returned future is polled, so output produced between this call and the first
.await cannot race ahead of the matcher.
The waiter starts at the earliest output currently available to new consumers. With replay enabled and unsealed, that can include retained past output; otherwise it starts at live output.
When chunks are dropped in DeliveryGuarantee::LossyWithoutBackpressure mode, this waiter discards
any partial line in progress and resynchronizes at the next newline instead of matching
across the gap.
§Errors
Returns crate::StreamReadError if the underlying stream fails while being read.
§Panics
Panics if options.max_line_length is zero.
Trait Implementations§
Source§impl<D, R> Consumable for BroadcastOutputStream<D, R>
impl<D, R> Consumable for BroadcastOutputStream<D, R>
Source§type Error = Infallible
type Error = Infallible
Subscribable::SubscribeError so the default consume / consume_async impls can
propagate subscription failures.Source§fn consume<V>(&self, visitor: V) -> Result<Consumer<V::Output>, Self::Error>where
V: StreamVisitor,
Self: OutputStream,
fn consume<V>(&self, visitor: V) -> Result<Consumer<V::Output>, Self::Error>where
V: StreamVisitor,
Self: OutputStream,
StreamVisitor over this stream and returns a
Consumer that owns the spawned task. Read moreSource§fn consume_async<V>(
&self,
visitor: V,
) -> Result<Consumer<V::Output>, Self::Error>where
V: AsyncStreamVisitor,
Self: OutputStream,
fn consume_async<V>(
&self,
visitor: V,
) -> Result<Consumer<V::Output>, Self::Error>where
V: AsyncStreamVisitor,
Self: OutputStream,
AsyncStreamVisitor over this stream and
returns a Consumer that owns the spawned task. Read moreSource§impl<D, R> Debug for BroadcastOutputStream<D, R>
impl<D, R> Debug for BroadcastOutputStream<D, R>
Source§impl<D, R> Drop for BroadcastOutputStream<D, R>
impl<D, R> Drop for BroadcastOutputStream<D, R>
Source§impl<D, R> OutputStream for BroadcastOutputStream<D, R>
impl<D, R> OutputStream for BroadcastOutputStream<D, R>
Source§fn read_chunk_size(&self) -> NumBytes
fn read_chunk_size(&self) -> NumBytes
stream_reader.Source§fn max_buffered_chunks(&self) -> usize
fn max_buffered_chunks(&self) -> usize
Source§impl<D, R> Subscribable for BroadcastOutputStream<D, R>
impl<D, R> Subscribable for BroadcastOutputStream<D, R>
Source§type Subscription = BroadcastSubscription<D, R>
type Subscription = BroadcastSubscription<D, R>
try_subscribe.