Trait apalis::prelude::Storage

source ·
pub trait Storage: Backend<Request<Self::Job>> {
    type Job: Job;
    type Error;
    type Identifier;

    // Required methods
    fn push(
        &mut self,
        job: Self::Job
    ) -> impl Future<Output = Result<Self::Identifier, Self::Error>> + Send;
    fn schedule(
        &mut self,
        job: Self::Job,
        on: i64
    ) -> impl Future<Output = Result<Self::Identifier, Self::Error>> + Send;
    fn len(&self) -> impl Future<Output = Result<i64, Self::Error>> + Send;
    fn fetch_by_id(
        &self,
        job_id: &Self::Identifier
    ) -> impl Future<Output = Result<Option<Request<Self::Job>>, Self::Error>> + Send;
    fn update(
        &self,
        job: Request<Self::Job>
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn reschedule(
        &mut self,
        job: Request<Self::Job>,
        wait: Duration
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn is_empty(&self) -> impl Future<Output = Result<bool, Self::Error>> + Send;
    fn vacuum(&self) -> impl Future<Output = Result<usize, Self::Error>> + Send;
}
Expand description

Represents a Storage that can persist a request. The underlying type must implement Job

Required Associated Types§

source

type Job: Job

The type of job that can be persisted

source

type Error

The error produced by the storage

source

type Identifier

Jobs must have Ids.

Required Methods§

source

fn push( &mut self, job: Self::Job ) -> impl Future<Output = Result<Self::Identifier, Self::Error>> + Send

Pushes a job to a storage

source

fn schedule( &mut self, job: Self::Job, on: i64 ) -> impl Future<Output = Result<Self::Identifier, Self::Error>> + Send

Push a job into the scheduled set

source

fn len(&self) -> impl Future<Output = Result<i64, Self::Error>> + Send

Return the number of pending jobs from the queue

source

fn fetch_by_id( &self, job_id: &Self::Identifier ) -> impl Future<Output = Result<Option<Request<Self::Job>>, Self::Error>> + Send

Fetch a job given an id

source

fn update( &self, job: Request<Self::Job> ) -> impl Future<Output = Result<(), Self::Error>> + Send

Update a job details

source

fn reschedule( &mut self, job: Request<Self::Job>, wait: Duration ) -> impl Future<Output = Result<(), Self::Error>> + Send

Reschedule a job

source

fn is_empty(&self) -> impl Future<Output = Result<bool, Self::Error>> + Send

Returns true if there is no jobs in the storage

source

fn vacuum(&self) -> impl Future<Output = Result<usize, Self::Error>> + Send

Vacuum the storage, removes done and killed jobs

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> Storage for MysqlStorage<T>
where T: Job + Serialize + DeserializeOwned + Send + 'static + Unpin + Sync,

§

type Job = T

§

type Error = Error

§

type Identifier = TaskId

source§

impl<T> Storage for PostgresStorage<T>
where T: Job + Serialize + DeserializeOwned + Send + 'static + Unpin + Sync,

§

type Job = T

§

type Error = Error

§

type Identifier = TaskId

source§

impl<T> Storage for RedisStorage<T>
where T: Serialize + DeserializeOwned + Send + 'static + Unpin + Job + Sync,

source§

impl<T> Storage for SqliteStorage<T>
where T: Job + Serialize + DeserializeOwned + Send + 'static + Unpin + Sync,

§

type Job = T

§

type Error = Error

§

type Identifier = TaskId