pub struct WorkerHandle { /* private fields */ }Expand description
Owns a running queue worker and exposes asynchronous processing failures.
The handle buffers at most 256 undrained errors. When the buffer is full,
newer errors are dropped, counted by Self::dropped_errors and emitted as
tracing warnings, so a handle that is kept alive but never drained does
not grow memory. Drain Self::next_error to observe every failure.
Implementations§
Source§impl WorkerHandle
impl WorkerHandle
Sourcepub async fn next_error(&mut self) -> Option<QueueError>
pub async fn next_error(&mut self) -> Option<QueueError>
Waits for the next driver, handler, timeout, or state-transition error.
Sourcepub fn try_next_error(&mut self) -> Option<QueueError>
pub fn try_next_error(&mut self) -> Option<QueueError>
Returns an already reported worker error without waiting.
Sourcepub fn dropped_errors(&self) -> u64
pub fn dropped_errors(&self) -> u64
Returns how many errors were dropped because the buffer was full.
Sourcepub async fn shutdown(self) -> Result<(), QueueError>
pub async fn shutdown(self) -> Result<(), QueueError>
Stops polling, cancels active handlers, and requeues interrupted jobs when the driver supports recoverable processing states.
Only a handler that was actually cancelled is requeued. A handler that finishes before its cancellation takes effect is completed or failed from its own result, so a success is not run a second time.
A claim that is already in flight is allowed to finish, so shutdown can
wait for one pop call. A job claimed after shutdown was requested is
requeued rather than dispatched. Dropping the handle instead aborts the
worker immediately; a claim interrupted that way is returned only by
stalled-lease recovery.
§Errors
Returns the first processing error reported before shutdown.