apalis_core::backend

Trait Backend

Source
pub trait Backend<Req, Res> {
    type Stream: Stream<Item = Result<Option<Req>, Error>>;
    type Layer;

    // Required method
    fn poll<Svc: Service<Req, Response = Res>>(
        self,
        worker: &Worker<Context>,
    ) -> Poller<Self::Stream, Self::Layer>;
}
Expand description

A backend represents a task source Both Storage and MessageQueue need to implement it for workers to be able to consume tasks

Required Associated Types§

Source

type Stream: Stream<Item = Result<Option<Req>, Error>>

The stream to be produced by the backend

Source

type Layer

Returns the final decoration of layers

Required Methods§

Source

fn poll<Svc: Service<Req, Response = Res>>( self, worker: &Worker<Context>, ) -> Poller<Self::Stream, Self::Layer>

Returns a poller that is ready for streaming

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, Res, Ctx> Backend<Request<T, Ctx>, Res> for RequestStream<Request<T, Ctx>>

Source§

type Stream = Pin<Box<dyn Stream<Item = Result<Option<Request<T, Ctx>>, Error>> + Send>>

Source§

type Layer = Identity

Source§

impl<T: Send + 'static + Sync, Res> Backend<Request<T, ()>, Res> for MemoryStorage<T>