pub trait QueueJobRepository: Send + Sync {
type Error;
// Required methods
fn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn schedule_later<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
scheduled_at: DateTime<Utc>,
schedule_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn reserve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
worker: &'life2 Worker,
queues: &'life3 [&'life4 str],
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Job>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn mark_as_completed<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn mark_as_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn retry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
id: Ulid,
delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn schedule_available_jobs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
A QueueJobRepository
is used to schedule jobs to be executed by a
worker.
Required Associated Types§
Required Methods§
sourcefn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Schedule a job to be executed as soon as possible by a worker.
§Parameters
rng
- The random number generator used to generate a new job IDclock
- The clock used to generate timestampsqueue_name
- The name of the queue to schedule the job onpayload
- The payload of the jobmetadata
- Arbitrary metadata about the job scheduled immediately.
§Errors
Returns an error if the underlying repository fails.
sourcefn schedule_later<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
scheduled_at: DateTime<Utc>,
schedule_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn schedule_later<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
queue_name: &'life3 str,
payload: Value,
metadata: Value,
scheduled_at: DateTime<Utc>,
schedule_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Schedule a job to be executed at a later date by a worker.
§Parameters
rng
- The random number generator used to generate a new job IDclock
- The clock used to generate timestampsqueue_name
- The name of the queue to schedule the job onpayload
- The payload of the jobmetadata
- Arbitrary metadata about the job scheduled immediately.scheduled_at
- The date and time to schedule the job forschedule_name
- The name of the recurring schedule which scheduled this job
§Errors
Returns an error if the underlying repository fails.
sourcefn reserve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
worker: &'life2 Worker,
queues: &'life3 [&'life4 str],
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Job>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn reserve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
worker: &'life2 Worker,
queues: &'life3 [&'life4 str],
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Job>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
sourcefn mark_as_completed<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_as_completed<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
sourcefn mark_as_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_as_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
id: Ulid,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
sourcefn retry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
id: Ulid,
delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn retry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
rng: &'life1 mut (dyn RngCore + Send),
clock: &'life2 dyn Clock,
id: Ulid,
delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
sourcefn schedule_available_jobs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn schedule_available_jobs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
clock: &'life1 dyn Clock,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark all scheduled jobs past their scheduled date as available to be executed.
Returns the number of jobs that were marked as available.
§Errors
Returns an error if the underlying repository fails.