pub trait Backend {
type Args;
type IdType: Clone;
type Context: Default;
type Error;
type Codec: Codec<Self::Args, Compact = Self::Compact>;
type Compact;
type Stream: Stream<Item = Result<Option<Task<Self::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§
Sourcetype Codec: Codec<Self::Args, Compact = Self::Compact>
type Codec: Codec<Self::Args, Compact = Self::Compact>
The codec used for serialization/deserialization of tasks.
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.
Implementors§
Source§impl<Args> Backend for JsonStorage<Args>
Available on crate feature json only.
impl<Args> Backend for JsonStorage<Args>
Available on crate feature
json only.