Trait apalis_core::worker::Worker
source · pub trait Worker<Job>: Sized {
type Service;
type Source;
// Required methods
fn id(&self) -> WorkerId;
fn start<'async_trait, E>(
self,
ctx: WorkerContext<E>
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where E: 'async_trait + Executor + Send + Sync + 'static,
Self: 'async_trait;
}Expand description
The Worker trait represents a type that can execute jobs. It is used
to define workers that can be managed by the Monitor.
Each Worker implementation must define a start method that takes a
WorkerContext and returns a Result indicating whether the worker
was able to execute its jobs successfully or not.
Required Associated Types§
Required Methods§
sourcefn start<'async_trait, E>(
self,
ctx: WorkerContext<E>
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
E: 'async_trait + Executor + Send + Sync + 'static,
Self: 'async_trait,
fn start<'async_trait, E>( self, ctx: WorkerContext<E> ) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where E: 'async_trait + Executor + Send + Sync + 'static, Self: 'async_trait,
Starts the worker, taking ownership of self and the provided ctx.
This method should run indefinitely or until it returns an error.
If an error occurs, it should return a WorkerError describing
the reason for the failure.
Object Safety§
This trait is not object safe.