Trait reactive_messaging::prelude::ChannelCommon
source · pub trait ChannelCommon<'a, ItemType, DerivedItemType>where
ItemType: Debug + Send + Sync,
DerivedItemType: Debug,{
// Required methods
fn new<IntoString>(name: IntoString) -> Arc<Self>
where IntoString: Into<String>;
fn flush<'life0, 'async_trait>(
&'life0 self,
timeout: Duration
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn is_channel_open(&self) -> bool;
fn gracefully_end_stream<'life0, 'async_trait>(
&'life0 self,
stream_id: u32,
timeout: Duration
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn gracefully_end_all_streams<'life0, 'async_trait>(
&'life0 self,
timeout: Duration
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn cancel_all_streams(&self);
fn running_streams_count(&self) -> u32;
fn pending_items_count(&self) -> u32;
fn buffer_size(&self) -> u32;
}Expand description
Defines common abstractions on how [Uni]s receives produced events and delivers them to Streams.
Implementors should also implement one of ChannelProducer or [UniZeroCopyChannel].
NOTE: all async functions are out of the hot path, so the async_trait won’t impose performance penalties
Required Methods§
sourcefn new<IntoString>(name: IntoString) -> Arc<Self>where
IntoString: Into<String>,
fn new<IntoString>(name: IntoString) -> Arc<Self>where IntoString: Into<String>,
Creates a new instance of this channel, to be referred to (in logs) as name
sourcefn flush<'life0, 'async_trait>(
&'life0 self,
timeout: Duration
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn flush<'life0, 'async_trait>( &'life0 self, timeout: Duration ) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where 'life0: 'async_trait, Self: 'async_trait,
Waits until all pending items are taken from this channel, up until timeout elapses.
Returns the number of still unconsumed items – which is 0 if it was not interrupted by the timeout
sourcefn is_channel_open(&self) -> bool
fn is_channel_open(&self) -> bool
Tells weather this channel is still enabled to process elements (true before calling the “end stream” / “cancel stream” functions)
sourcefn gracefully_end_stream<'life0, 'async_trait>(
&'life0 self,
stream_id: u32,
timeout: Duration
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn gracefully_end_stream<'life0, 'async_trait>( &'life0 self, stream_id: u32, timeout: Duration ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where 'life0: 'async_trait, Self: 'async_trait,
Flushes & signals that the given stream_id should cease its activities when there are no more elements left
to process, waiting for the operation to complete for up to timeout.
Returns true if the stream ended within the given timeout or false if it is still processing elements.
sourcefn gracefully_end_all_streams<'life0, 'async_trait>(
&'life0 self,
timeout: Duration
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn gracefully_end_all_streams<'life0, 'async_trait>( &'life0 self, timeout: Duration ) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where 'life0: 'async_trait, Self: 'async_trait,
Flushes & signals that all streams should cease their activities when there are no more elements left
to process, waiting for the operation to complete for up to timeout.
Returns the number of un-ended streams – which is 0 if it was not interrupted by the timeout
sourcefn cancel_all_streams(&self)
fn cancel_all_streams(&self)
Sends a signal to all streams, urging them to cease their operations.
In opposition to [end_all_streams()], this method does not wait for any confirmation,
nor cares if there are remaining elements to be processed.
sourcefn running_streams_count(&self) -> u32
fn running_streams_count(&self) -> u32
Informs the caller how many active streams are currently managed by this channel IMPLEMENTORS: #[inline(always)]
sourcefn pending_items_count(&self) -> u32
fn pending_items_count(&self) -> u32
Tells how many events are waiting to be taken out of this channel.
IMPLEMENTORS: #[inline(always)]
sourcefn buffer_size(&self) -> u32
fn buffer_size(&self) -> u32
Tells how many events may be produced ahead of the consumers.
IMPLEMENTORS: #[inline(always)]