pub struct Worker<B: Broker> { /* private fields */ }Expand description
The worker loop that dequeues and executes tasks.
Implementations§
Source§impl<B: Broker> Worker<B>
impl<B: Broker> Worker<B>
Sourcepub fn new(
broker: B,
registry: TaskRegistry,
context: TaskContext,
config: WorkerConfig,
) -> Self
pub fn new( broker: B, registry: TaskRegistry, context: TaskContext, config: WorkerConfig, ) -> Self
Create a new worker with the given broker, task registry, shared context, and config.
Prefer KojinBuilder (from the kojin facade crate) for ergonomic construction.
Sourcepub fn with_result_backend(self, backend: Arc<dyn ResultBackend>) -> Self
pub fn with_result_backend(self, backend: Arc<dyn ResultBackend>) -> Self
Set the result backend.
Sourcepub fn with_middleware(self, middleware: impl Middleware) -> Self
pub fn with_middleware(self, middleware: impl Middleware) -> Self
Add middleware to the worker pipeline.
Sourcepub fn with_middleware_boxed(self, middleware: Box<dyn Middleware>) -> Self
pub fn with_middleware_boxed(self, middleware: Box<dyn Middleware>) -> Self
Add a boxed middleware to the worker pipeline.
Sourcepub fn cancel_token(&self) -> CancellationToken
pub fn cancel_token(&self) -> CancellationToken
Get the cancellation token for external shutdown triggering.
Auto Trait Implementations§
impl<B> Freeze for Worker<B>
impl<B> !RefUnwindSafe for Worker<B>
impl<B> Send for Worker<B>
impl<B> Sync for Worker<B>
impl<B> Unpin for Worker<B>
impl<B> UnsafeUnpin for Worker<B>
impl<B> !UnwindSafe for Worker<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more