pub trait Backend<Args> {
type IdType: Clone;
type Context: Default;
type Error;
type Codec;
type Stream: Stream<Item = Result<Option<Task<Args, Self::Context, Self::IdType>>, Self::Error>>;
type Beat: Stream<Item = Result<(), Self::Error>>;
type Layer;
// Required methods
fn heartbeat(&self, worker: &WorkerContext) -> Self::Beat;
fn middleware(&self) -> Self::Layer;
fn poll(self, worker: &WorkerContext) -> Self::Stream;
}Expand description
The Backend trait defines how workers get and manage tasks from a backend.
In other languages, this might be called a “Queue”, “Broker”, etc.
Required Associated Types§
Required Methods§
Sourcefn heartbeat(&self, worker: &WorkerContext) -> Self::Beat
fn heartbeat(&self, worker: &WorkerContext) -> Self::Beat
Returns a heartbeat stream for the given worker.
Sourcefn middleware(&self) -> Self::Layer
fn middleware(&self) -> Self::Layer
Returns the backend’s middleware layer.
Sourcefn poll(self, worker: &WorkerContext) -> Self::Stream
fn poll(self, worker: &WorkerContext) -> Self::Stream
Polls the backend for tasks for the given worker.