pub struct StreamExecutor<const INSTRUMENTS_USIZE: usize> {
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<const INSTRUMENTS_USIZE: usize> StreamExecutor<INSTRUMENTS_USIZE>
impl<const INSTRUMENTS_USIZE: usize> StreamExecutor<INSTRUMENTS_USIZE>
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
Sourcepub fn spawn_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = FutureItemType> + Send + 'static,
)
pub fn spawn_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = FutureItemType> + Send + 'static, )
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’s Future
a resolution timeout.
stream_ended_callback()
should be either a closure or a generic function declared with <StreamExecutorType: StreamExecutorStats>(executor_stats: Arc<StreamExecutorStats>)
Sourcepub fn spawn_futures_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = FutureItemType> + Send + 'static,
)
pub fn spawn_futures_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = FutureItemType> + Send + 'static, )
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.
stream_ended_callback()
should be either a closure or a generic function declared with <StreamExecutorType: StreamExecutorStats>(executor_stats: Arc<StreamExecutorStats>)
Sourcepub fn spawn_fallibles_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = Result<OutItemType, Box<dyn Error + Send + Sync>>> + Send + 'static,
)
pub fn spawn_fallibles_executor<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<dyn StreamExecutorStats + Send + Sync>) -> CloseVoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = Result<OutItemType, Box<dyn Error + Send + Sync>>> + Send + 'static, )
Spawns an optimized executor for a Stream of FallibleItemType
s, where:\
FallibleItemType := Result<OutItemType, Box<dyn std::error::Error + Send + Sync>>
stream_ended_callback()
should be either a closure or a generic function declared with <StreamExecutorType: StreamExecutorStats>(executor_stats: Arc<StreamExecutorStats>)
Sourcepub fn spawn_non_futures_executor<ItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
stream_ended_callback: impl FnOnce(Arc<dyn StreamExecutorStats + Send + Sync>) -> VoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = Result<ItemType, Box<dyn Error + Send + Sync>>> + Send + 'static,
)
pub fn spawn_non_futures_executor<ItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, stream_ended_callback: impl FnOnce(Arc<dyn StreamExecutorStats + Send + Sync>) -> VoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = Result<ItemType, Box<dyn Error + Send + Sync>>> + Send + 'static, )
Spawns an executor for a Stream of ItemType
s which are not Futures but are fallible:
InnerFallibleType := Result<ItemType, Box<dyn std::error::Error>>
stream_ended_callback()
should be either a closure or a generic function declared with <StreamExecutorType: StreamExecutorStats>(executor_stats: Arc<StreamExecutorStats>)
Sourcepub fn spawn_non_futures_non_fallibles_executor<OutItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>(
self: Arc<Self>,
concurrency_limit: u32,
stream_ended_callback: impl FnOnce(Arc<dyn StreamExecutorStats + Send + Sync>) -> VoidAsyncType + Send + Sync + 'static,
stream: impl Stream<Item = OutItemType> + Send + 'static,
)
pub fn spawn_non_futures_non_fallibles_executor<OutItemType: Send + Debug, VoidAsyncType: Future<Output = ()> + Send + 'static>( self: Arc<Self>, concurrency_limit: u32, stream_ended_callback: impl FnOnce(Arc<dyn StreamExecutorStats + Send + Sync>) -> VoidAsyncType + Send + Sync + 'static, stream: impl Stream<Item = OutItemType> + Send + 'static, )
Spawns an optimized executor for a Stream of ItemType
s which are not Futures and, also, are not fallible.
stream_ended_callback()
should be either a closure or a generic function declared with <StreamExecutorType: StreamExecutorStats>(executor_stats: Arc<StreamExecutorStats>)