pub trait ReservedJob:
Send
+ Sync
+ 'static {
// Required methods
fn queue(&self) -> &str;
fn payload(&self) -> &str;
fn attempts(&self) -> u32;
fn renew(&self) -> impl Future<Output = Result<Reservation, Error>> + Send;
fn delete(&self) -> impl Future<Output = Result<Reservation, Error>> + Send;
fn release(
&self,
delay: Duration,
) -> impl Future<Output = Result<Reservation, Error>> + Send;
// Provided method
fn fail(
&self,
error: &Error,
) -> impl Future<Output = Result<Failed, Error>> + Send { ... }
}Expand description
One reservation of a job, which a worker runs and then settles.
When the reservation has lapsed and another worker has taken the job, renew, delete, and
release return Reservation::Lost, and fail returns Failed::Lost. The worker then
leaves the job alone.
Required Methods§
Sourcefn attempts(&self) -> u32
fn attempts(&self) -> u32
How many times the job has been reserved, including this time.
The count is the run’s number, starting at 1. Releases, retries, and reservations that lapsed all count.
Sourcefn delete(&self) -> impl Future<Output = Result<Reservation, Error>> + Send
fn delete(&self) -> impl Future<Output = Result<Reservation, Error>> + Send
Remove the job, and return whether it was still this worker’s.
§Errors
Fails when the backend can’t be reached.
Sourcefn release(
&self,
delay: Duration,
) -> impl Future<Output = Result<Reservation, Error>> + Send
fn release( &self, delay: Duration, ) -> impl Future<Output = Result<Reservation, Error>> + Send
Put the job back on its queue to become available after delay, and return whether it was
still this worker’s.
The released job keeps its identity and its count of attempts.
§Errors
Fails when the backend can’t be reached.
Provided Methods§
Sourcefn fail(
&self,
error: &Error,
) -> impl Future<Output = Result<Failed, Error>> + Send
fn fail( &self, error: &Error, ) -> impl Future<Output = Result<Failed, Error>> + Send
Remove a job that failed for good with error, and return what became of it.
By default, this method deletes the job, and the worker stores it with the
application’s failed jobs. A driver whose backend keeps failed jobs itself, such as the Laravel
Cloud driver, records the failure there and returns Failed::Kept.
§Errors
Fails when the backend can’t be reached.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".