Skip to main content

BroadcastOutputStream

Struct BroadcastOutputStream 

Source
pub struct BroadcastOutputStream<D = LossyWithoutBackpressure, R = NoReplay>
where D: Delivery, R: Replay,
{ /* 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,

Source

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.

Source

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>
where D: Delivery, R: Replay,

Source

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>
where D: Delivery, R: Replay,

Source§

type Error = Infallible

Error returned when consumer creation fails. Must be constructible from the underlying 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,

Tries to drive the provided synchronous StreamVisitor over this stream and returns a Consumer that owns the spawned task. Read more
Source§

fn consume_async<V>( &self, visitor: V, ) -> Result<Consumer<V::Output>, Self::Error>

Tries to drive the provided asynchronous AsyncStreamVisitor over this stream and returns a Consumer that owns the spawned task. Read more
Source§

impl<D, R> Debug for BroadcastOutputStream<D, R>
where D: Delivery + Debug, R: Replay + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D, R> Drop for BroadcastOutputStream<D, R>
where D: Delivery, R: Replay,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<D, R> OutputStream for BroadcastOutputStream<D, R>
where D: Delivery, R: Replay,

Source§

fn read_chunk_size(&self) -> NumBytes

The maximum size of every chunk read by the backing stream_reader.
Source§

fn max_buffered_chunks(&self) -> usize

The number of chunks held by the underlying async channel.
Source§

fn name(&self) -> &'static str

Type of stream. Can be “stdout” or “stderr”. But we do not guarantee this output. It should only be used for logging/debugging.
Source§

impl<D, R> Subscribable for BroadcastOutputStream<D, R>
where D: Delivery, R: Replay,

Source§

type Subscription = BroadcastSubscription<D, R>

The concrete subscription handle returned by try_subscribe.
Source§

type SubscribeError = Infallible

The error returned when subscription fails.
Source§

fn try_subscribe(&self) -> Result<Self::Subscription, Self::SubscribeError>

Creates a new subscription for a consumer, or returns why the consumer cannot be started. Read more

Auto Trait Implementations§

§

impl<D, R> Freeze for BroadcastOutputStream<D, R>
where D: Freeze, R: Freeze,

§

impl<D, R> RefUnwindSafe for BroadcastOutputStream<D, R>

§

impl<D, R> Send for BroadcastOutputStream<D, R>

§

impl<D, R> Sync for BroadcastOutputStream<D, R>

§

impl<D, R> Unpin for BroadcastOutputStream<D, R>
where D: Unpin, R: Unpin,

§

impl<D, R> UnsafeUnpin for BroadcastOutputStream<D, R>
where D: UnsafeUnpin, R: UnsafeUnpin,

§

impl<D, R> UnwindSafe for BroadcastOutputStream<D, R>
where D: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Sink for T
where T: Send + 'static,