Skip to main content

ReservedJob

Trait ReservedJob 

Source
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§

Source

fn queue(&self) -> &str

The queue the job was reserved from.

Source

fn payload(&self) -> &str

The payload, unchanged from when it was pushed.

Source

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.

Source

fn renew(&self) -> impl Future<Output = Result<Reservation, Error>> + Send

Extend the reservation to LEASE from now, and return whether the job is still this worker’s.

§Errors

Fails when the backend can’t be reached.

Source

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.

Source

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§

Source

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".

Implementors§