Struct reactive_mutiny::stream_executor::StreamExecutor
source · pub struct StreamExecutor {
pub ok_events_avg_future_duration: AtomicIncrementalAverage64,
pub timed_out_events_avg_future_duration: AtomicIncrementalAverage64,
pub failed_events_avg_future_duration: AtomicIncrementalAverage64,
/* private fields */
}
Expand description
See Instruments
Fields§
§ok_events_avg_future_duration: AtomicIncrementalAverage64
computes: counter of successful events & average times (seconds) for the future resolution
timed_out_events_avg_future_duration: AtomicIncrementalAverage64
computes: counter of timed out events & average times (seconds) for the failed future resolution (even if it should be ~ constant) – events computed here are NOT computed at [failed_events_avg_future_duration]
failed_events_avg_future_duration: AtomicIncrementalAverage64
computes: counter of all other failed events & average times (seconds) for the failed future resolution (timed out events, computed by [timed_out_events_avg_future_duration], are NOT computed here)
Implementations§
source§impl StreamExecutor
impl StreamExecutor
sourcepub fn new<IntoString: Into<String>>(executor_name: IntoString) -> Arc<Self>
pub fn new<IntoString: Into<String>>(executor_name: IntoString) -> Arc<Self>
Initializes an executor that should not timeout any futures returned by the Stream
sourcepub fn with_futures_timeout<IntoString: Into<String>>(
executor_name: IntoString,
futures_timeout: Duration
) -> Arc<Self>
pub fn with_futures_timeout<IntoString: Into<String>>( executor_name: IntoString, futures_timeout: Duration ) -> Arc<Self>
Initializes an executor that should be able to timeout
Futures returned by the Stream
pub fn executor_name(&self) -> String
sourcepub fn report_scheduled_to_finish(&self)
pub fn report_scheduled_to_finish(&self)
Tells this executor that its Stream will be artificially ended – so to cause it to cease its execution
sourcepub fn spawn_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, FutureItemType: Future<Output = Result<OutItemType, Box<dyn Error + Send + Sync>>> + Send, CloseVoidAsyncType: Future<Output = ()> + Send + 'static, ErrVoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
on_err_callback: impl Fn(Box<dyn Error + Send + Sync>) -> ErrVoidAsyncType + Send + Sync + 'static,
stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = FutureItemType> + 'static + Send
)
pub fn spawn_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, FutureItemType: Future<Output = Result<OutItemType, Box<dyn Error + Send + Sync>>> + Send, CloseVoidAsyncType: Future<Output = ()> + Send + 'static, ErrVoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, on_err_callback: impl Fn(Box<dyn Error + Send + Sync>) -> ErrVoidAsyncType + Send + Sync + 'static, stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = FutureItemType> + 'static + Send )
Spawns an optimized executor for a Stream of ItemType
s which are:
- Futures –
ItemType := Future<Output=InnerFallibleType>
- Fallible –
InnerFallibleType := Result<InnerType, Box<dyn std::error::Error>>.
NOTE: special (optimized) versions are spawned depending if we should or not enforce each item’sFuture
a resolution timeout
sourcepub fn spawn_futures_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, FutureItemType: Future<Output = OutItemType> + Send, CloseVoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = FutureItemType> + 'static + Send
)
pub fn spawn_futures_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, FutureItemType: Future<Output = OutItemType> + Send, CloseVoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = FutureItemType> + 'static + Send )
Spawns an optimized executor for a Stream
of FutureItemType
s (non fallible Futures).
NOTE: Since this is non-fallible, timeouts are enforced but not detectable. If that is not acceptable, use Self::spawn_executor() instead
sourcepub fn spawn_fallibles_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, CloseVoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
on_err_callback: impl Fn(Box<dyn Error + Send + Sync>) + Send + Sync + 'static,
stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = Result<OutItemType, Box<dyn Error + Send + Sync>>> + 'static + Send
)
pub fn spawn_fallibles_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, CloseVoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, on_err_callback: impl Fn(Box<dyn Error + Send + Sync>) + Send + Sync + 'static, stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = Result<OutItemType, Box<dyn Error + Send + Sync>>> + 'static + Send )
Spawns an optimized executor for a Stream of FallibleItemType
s, where:
FallibleItemType := Result<OutItemType, Box<dyn std::error::Error + Send + Sync>>
sourcepub fn spawn_non_futures_executor<const INSTRUMENTS: usize, ItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> VoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = Result<ItemType, Box<dyn Error + Send + Sync>>> + 'static + Send
)
pub fn spawn_non_futures_executor<const INSTRUMENTS: usize, ItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> VoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = Result<ItemType, Box<dyn Error + Send + Sync>>> + 'static + Send )
Spawns an executor for a Stream of ItemType
s which are not Futures but are fallible:
InnerFallibleType := Result<ItemType, Box<dyn std::error::Error>>
sourcepub fn spawn_non_futures_non_fallibles_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> VoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = OutItemType> + 'static + Send
)
pub fn spawn_non_futures_non_fallibles_executor<const INSTRUMENTS: usize, OutItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, stream_ended_callback: impl FnOnce(Arc<StreamExecutor>) -> VoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = OutItemType> + 'static + Send )
Spawns an optimized executor for a Stream of ItemType
s which are not Futures and, also, are not fallible