Struct StreamExecutor

Source
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

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>

Source

pub fn new<IntoString: Into<String>>(executor_name: IntoString) -> Arc<Self>

Initializes an executor that should not timeout any futures returned by the Stream

Source

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

Source

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 ItemTypes 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>)

Source

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 FutureItemTypes (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>)

Source

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 FallibleItemTypes, 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>)

Source

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 ItemTypes 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>)

Source

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 ItemTypes 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>)

Trait Implementations§

Source§

impl<const INSTRUMENTS_USIZE: usize> Debug for StreamExecutor<INSTRUMENTS_USIZE>

Source§

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

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

impl<const INSTRUMENTS_USIZE: usize> StreamExecutorStats for StreamExecutor<INSTRUMENTS_USIZE>

Source§

fn executor_name(&self) -> &String

Source§

fn futures_timeout(&self) -> &Duration

Source§

fn creation_time(&self) -> &Instant

Source§

fn executor_status(&self) -> &AtomicExecutorStatus

Source§

fn execution_start_delta_nanos(&self) -> u64

Source§

fn execution_finish_delta_nanos(&self) -> u64

Source§

fn ok_events_avg_future_duration(&self) -> &AtomicIncrementalAverage64

Source§

fn timed_out_events_avg_future_duration(&self) -> &AtomicIncrementalAverage64

Source§

fn failed_events_avg_future_duration(&self) -> &AtomicIncrementalAverage64

Source§

fn report_scheduled_to_finish(&self)

Tells this executor that its Stream will be artificially ended – so to cause it to cease its execution

Auto Trait Implementations§

§

impl<const INSTRUMENTS_USIZE: usize> !Freeze for StreamExecutor<INSTRUMENTS_USIZE>

§

impl<const INSTRUMENTS_USIZE: usize> RefUnwindSafe for StreamExecutor<INSTRUMENTS_USIZE>

§

impl<const INSTRUMENTS_USIZE: usize> Send for StreamExecutor<INSTRUMENTS_USIZE>

§

impl<const INSTRUMENTS_USIZE: usize> Sync for StreamExecutor<INSTRUMENTS_USIZE>

§

impl<const INSTRUMENTS_USIZE: usize> Unpin for StreamExecutor<INSTRUMENTS_USIZE>

§

impl<const INSTRUMENTS_USIZE: usize> UnwindSafe for StreamExecutor<INSTRUMENTS_USIZE>

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Erased for T