Skip to main content

ScheduledTaskStore

Trait ScheduledTaskStore 

Source
pub trait ScheduledTaskStore:
    Clone
    + Send
    + Sync
    + 'static {
    type Error: Display + Send + Sync + 'static;

    // Required methods
    fn ensure_scheduled_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        entry: ScheduledTaskCatalogEntry<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn claim_scheduled_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        request: ScheduledTaskClaimRequest<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ScheduledTaskClaim>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn renew_scheduled_task_claim<'life0, 'life1, 'async_trait>(
        &'life0 self,
        renewal: ScheduledTaskClaimRenewal<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn complete_scheduled_task<'life0, 'async_trait>(
        &'life0 self,
        completion: ScheduledTaskCompletion,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Persistence contract used by scheduled task runners.

Required Associated Types§

Source

type Error: Display + Send + Sync + 'static

Store error type.

Required Methods§

Source

fn ensure_scheduled_task<'life0, 'life1, 'async_trait>( &'life0 self, entry: ScheduledTaskCatalogEntry<'life1>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Ensures one scheduled task is present in the catalog.

Source

fn claim_scheduled_task<'life0, 'life1, 'async_trait>( &'life0 self, request: ScheduledTaskClaimRequest<'life1>, ) -> Pin<Box<dyn Future<Output = Result<Option<ScheduledTaskClaim>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attempts to claim one due scheduled task firing.

Source

fn renew_scheduled_task_claim<'life0, 'life1, 'async_trait>( &'life0 self, renewal: ScheduledTaskClaimRenewal<'life1>, ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Renews an owned claim while the task body is still running.

Returning Ok(false) means the ownership predicate did not match, so the worker must treat the claim as lost and stop renewing. Returning Err(_) is treated as transient and retried on the next renewal tick.

Source

fn complete_scheduled_task<'life0, 'async_trait>( &'life0 self, completion: ScheduledTaskCompletion, ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Completes a claimed firing and advances the next due timestamp.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§