pub trait Queue:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn push<'a>(&'a self, job: QueuedJob) -> BoxFuture<'a, Result<String>>;
fn reserve<'a>(
&'a self,
queue: &'a str,
) -> BoxFuture<'a, Result<Option<QueuedJob>>>;
fn acknowledge<'a>(
&'a self,
job: &'a QueuedJob,
) -> BoxFuture<'a, Result<()>>;
fn release<'a>(
&'a self,
job: &'a QueuedJob,
delay: Duration,
) -> BoxFuture<'a, Result<()>>;
fn fail<'a>(
&'a self,
job: &'a QueuedJob,
error: &'a str,
) -> BoxFuture<'a, Result<()>>;
fn size<'a>(&'a self, queue: &'a str) -> BoxFuture<'a, Result<u64>>;
fn clear<'a>(&'a self, queue: &'a str) -> BoxFuture<'a, Result<u64>>;
}Expand description
A queue backend.
The contract is deliberately “reserve, then acknowledge” rather than “pop”: a worker that crashes mid-job must not lose it. A reserved job stays in the store, invisible to other workers, until it is acknowledged, released or its reservation times out.
Required Methods§
Sourcefn reserve<'a>(
&'a self,
queue: &'a str,
) -> BoxFuture<'a, Result<Option<QueuedJob>>>
fn reserve<'a>( &'a self, queue: &'a str, ) -> BoxFuture<'a, Result<Option<QueuedJob>>>
Reserve the next available job on queue, or None if there is none.
Sourcefn acknowledge<'a>(&'a self, job: &'a QueuedJob) -> BoxFuture<'a, Result<()>>
fn acknowledge<'a>(&'a self, job: &'a QueuedJob) -> BoxFuture<'a, Result<()>>
Remove a finished job.
Sourcefn release<'a>(
&'a self,
job: &'a QueuedJob,
delay: Duration,
) -> BoxFuture<'a, Result<()>>
fn release<'a>( &'a self, job: &'a QueuedJob, delay: Duration, ) -> BoxFuture<'a, Result<()>>
Return a job to the queue for another attempt, available after delay.
Sourcefn fail<'a>(
&'a self,
job: &'a QueuedJob,
error: &'a str,
) -> BoxFuture<'a, Result<()>>
fn fail<'a>( &'a self, job: &'a QueuedJob, error: &'a str, ) -> BoxFuture<'a, Result<()>>
Move a job to the failed store after its last attempt.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".