pub struct WorkerBuilder<Q: QueueSet, B: Backend> { /* private fields */ }Expand description
Configures a Worker. Created by Worker::builder.
Implementations§
Source§impl<Q: QueueSet, B: Backend> WorkerBuilder<Q, B>
impl<Q: QueueSet, B: Backend> WorkerBuilder<Q, B>
Sourcepub fn handler<H>(self, handler: H) -> Self
pub fn handler<H>(self, handler: H) -> Self
Register a handler.
The H::Job: Job<Queue = Q> bound is what makes the worker type-safe: a handler
for a job belonging to another queue set does not compile.
Sourcepub fn queues(self, queues: &[Q]) -> Self
pub fn queues(self, queues: &[Q]) -> Self
Consume only these queues instead of every queue in Q. Duplicates are ignored.
Sourcepub fn concurrency(self, concurrency: usize) -> Self
pub fn concurrency(self, concurrency: usize) -> Self
Cap the number of jobs running at the same time.
Defaults to the sum of the prefetch of the consumed queues. 0 is treated as 1.
Sourcepub fn job_timeout(self, timeout: Duration) -> Self
pub fn job_timeout(self, timeout: Duration) -> Self
Abort a handler that runs longer than timeout and treat it as a retryable failure.
Sourcepub fn close_backend_on_shutdown(self, close: bool) -> Self
pub fn close_backend_on_shutdown(self, close: bool) -> Self
Close the backend when Worker::run returns. Defaults to false.
The backend is an Arc that is normally shared with a crate::Producer (and
possibly other workers), so closing it is the caller’s decision: a worker that
closed it on its own would take those down with it. Turn this on for a process
whose only job is to run this worker, or call backend.close() yourself once
run() has returned.