pub struct Worker { /* private fields */ }Expand description
Pulls jobs off a queue and runs them.
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn with_locks(self, locks: LockManager) -> Self
pub fn with_locks(self, locks: LockManager) -> Self
Enforce unique_id releases with locks.
The same manager the dispatching side uses, or the release will not find
the key. Worker::from_manager wires it for you.
Sourcepub fn new(
queue: Arc<dyn Queue>,
registry: Arc<JobRegistry>,
container: Arc<Container>,
) -> Self
pub fn new( queue: Arc<dyn Queue>, registry: Arc<JobRegistry>, container: Arc<Container>, ) -> Self
A worker serving queue, running the jobs registry knows.
Sourcepub fn with_events(self, events: Arc<Dispatcher>) -> Self
pub fn with_events(self, events: Arc<Dispatcher>) -> Self
Fire lifecycle events through events.
Sourcepub fn with_options(self, options: WorkerOptions) -> Self
pub fn with_options(self, options: WorkerOptions) -> Self
Configure the loop.
Sourcepub fn is_stopping(&self) -> bool
pub fn is_stopping(&self) -> bool
Whether a stop has been requested.
Sourcepub async fn run_next(&self) -> Result<Outcome>
pub async fn run_next(&self) -> Result<Outcome>
Reserve and run one job from the first queue that has one.
Sourcepub async fn run(&self) -> Result<WorkerStats>
pub async fn run(&self) -> Result<WorkerStats>
Run until stopped, drained, or the job limit is reached.
Between jobs the worker flushes the container’s scoped bindings, so one job cannot leak per-request-shaped state into the next. That is the long-running-process hazard a per-request framework never has to think about.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Worker
impl !RefUnwindSafe for Worker
impl !UnwindSafe for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl UnsafeUnpin for Worker
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> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.