pub struct Worker<B>where
B: Broker,{ /* private fields */ }Expand description
The worker loop that dequeues and executes tasks.
Implementations§
Source§impl<B> Worker<B>where
B: Broker,
impl<B> Worker<B>where
B: Broker,
Sourcepub fn new(
broker: B,
registry: TaskRegistry,
context: TaskContext,
config: WorkerConfig,
) -> Worker<B>
pub fn new( broker: B, registry: TaskRegistry, context: TaskContext, config: WorkerConfig, ) -> Worker<B>
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>) -> Worker<B>
pub fn with_result_backend(self, backend: Arc<dyn ResultBackend>) -> Worker<B>
Set the result backend.
Sourcepub fn with_middleware(self, middleware: impl Middleware) -> Worker<B>
pub fn with_middleware(self, middleware: impl Middleware) -> Worker<B>
Add middleware to the worker pipeline.
Sourcepub fn with_middleware_boxed(self, middleware: Box<dyn Middleware>) -> Worker<B>
pub fn with_middleware_boxed(self, middleware: Box<dyn Middleware>) -> Worker<B>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more