Skip to main content

RecurringStore

Trait RecurringStore 

Source
pub trait RecurringStore: Send + Sync {
    // Required methods
    fn upsert_recurring_job<'life0, 'life1, 'async_trait>(
        &'life0 self,
        job: &'life1 RecurringJob,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_recurring_job<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_recurring_jobs<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RecurringJob>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_due_recurring_jobs<'life0, 'async_trait>(
        &'life0 self,
        now: DateTime<Utc>,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RecurringJob>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Recurring-job templates — the storage side of cron-scheduled jobs.

Required Methods§

Source

fn upsert_recurring_job<'life0, 'life1, 'async_trait>( &'life0 self, job: &'life1 RecurringJob, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert or update a RecurringJob template, keyed by RecurringJob::id.

Source

fn remove_recurring_job<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a recurring-job template by id. Returns Ok(true) if the row existed and was removed, Ok(false) if the id was unknown.

Source

fn list_recurring_jobs<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<RecurringJob>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List recurring-job templates (for dashboards / operator tooling).

Source

fn fetch_due_recurring_jobs<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<RecurringJob>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically claim recurring-job templates whose next_run_at <= now and are enabled. Implementations use locking (Postgres: FOR UPDATE SKIP LOCKED; Redis: per-row SET NX) so two servers running the poller cannot double-fire the same tick.

Claimed rows are returned to the caller before next_run_at is advanced — the caller calls RecurringJob::advance and upsert_recurring_job to write the new next_run_at back. Cron expressions can’t be computed in the database.

Implementors§