Skip to main content

Processor

Trait Processor 

Source
pub trait Processor<T> {
    type Output;
    type Error;

    // Required methods
    fn process(&self, input: T) -> impl Future<Output = Result<(), Self::Error>>;
    fn next(&self) -> impl Future<Output = Result<Self::Output, Self::Error>>;
}
Expand description

Interface for implementing data processors.

Processors take in items (input) and yield “processed” or “enriched” versions of them at some point (output). Please note that these items do not necessarily need to come out in the same order as they came in. Processors can keep items around until their internal logic decides they’re ready to go, and this can happen in any order required.

Users of processors will use the process method to insert “input” items and call next to find out if there’s ready processed “output” items to take out.

The process method might apply back-pressure, for example when the processor is busy and can’t take in more work.

Processors never terminate. The future returned by next will stay in pending state whenever there’s no work to do or the processor can’t continue because of it’s internal logic. Users can decide to drop a processor or escalate to a higher-level whenever an error occurs or the processor is no longer used.

Required Associated Types§

Required Methods§

Source

fn process(&self, input: T) -> impl Future<Output = Result<(), Self::Error>>

Consumes an item for further processing.

Might apply back-pressure when being too busy.

Source

fn next(&self) -> impl Future<Output = Result<Self::Output, Self::Error>>

Returns future with processed output whenever ready.

Please note that processors never terminate and rather return pending state (Poll::Pending) in the future when next is called and no ready items are available.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P1, P2, T> Processor<T> for ComposedProcessors<P1, P2>
where P1: Processor<T>, P2: Processor<P1::Output>,

Source§

type Output = <P2 as Processor<<P1 as Processor<T>>::Output>>::Output

Source§

type Error = ComposedError<<P1 as Processor<T>>::Error, <P2 as Processor<<P1 as Processor<T>>::Output>>::Error>

Source§

impl<P, T> Processor<T> for Pipeline<P>
where P: Processor<T>,

Source§

type Output = <P as Processor<T>>::Output

Source§

type Error = <P as Processor<T>>::Error

Source§

impl<S, T, L, E, TP> Processor<T> for Ingest<S, T, L, E, TP>

Available on crate feature ingest only.
Source§

impl<S, T, L, E> Processor<T> for LogPrune<S, T, L, E>

Available on crate feature log_prune only.
Source§

impl<T, E, L, C> Processor<T> for Groups<T, E, L, C>

Available on crate feature groups only.
Source§

type Output = (T, GroupsResult)

Source§

type Error = (T, GroupsError<C>)

Source§

impl<T, ID, S> Processor<T> for Orderer<T, ID, S>
where T: Digest<ID> + Ordering<ID>, ID: OperationId, S: Transaction + OrdererStore<ID> + OperationStore<T, ID>,

Available on crate feature orderer only.
Source§

type Output = T

Source§

type Error = (Option<T>, OrdererError<T, ID, S>)

Source§

impl<T, S, F, C> Processor<T> for Spaces<T, S, F, C>

Available on crate feature spaces only.