Trait Storage

Source
pub trait Storage: Backend<Request<Self::Job, Self::Context>> {
    type Job;
    type Error;
    type Context: Default;
    type Compact;

    // Required methods
    fn push_request(
        &mut self,
        req: Request<Self::Job, Self::Context>,
    ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send;
    fn push_raw_request(
        &mut self,
        req: Request<Self::Compact, Self::Context>,
    ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send;
    fn schedule_request(
        &mut self,
        request: Request<Self::Job, Self::Context>,
        on: i64,
    ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send;
    fn len(&mut self) -> impl Future<Output = Result<i64, Self::Error>> + Send;
    fn fetch_by_id(
        &mut self,
        job_id: &TaskId,
    ) -> impl Future<Output = Result<Option<Request<Self::Job, Self::Context>>, Self::Error>> + Send;
    fn update(
        &mut self,
        job: Request<Self::Job, Self::Context>,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn reschedule(
        &mut self,
        job: Request<Self::Job, Self::Context>,
        wait: Duration,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn is_empty(
        &mut self,
    ) -> impl Future<Output = Result<bool, Self::Error>> + Send;
    fn vacuum(
        &mut self,
    ) -> impl Future<Output = Result<usize, Self::Error>> + Send;

    // Provided methods
    fn push(
        &mut self,
        job: Self::Job,
    ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send { ... }
    fn schedule(
        &mut self,
        job: Self::Job,
        on: i64,
    ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send { ... }
}
Expand description

Represents a Storage that can persist a request.

Required Associated Types§

Source

type Job

The type of job that can be persisted

Source

type Error

The error produced by the storage

Source

type Context: Default

This is the type that storages store as the metadata related to a job

Source

type Compact

The format that the storage persists the jobs usually Vec<u8>

Required Methods§

Source

fn push_request( &mut self, req: Request<Self::Job, Self::Context>, ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send

Pushes a constructed request to a storage

Source

fn push_raw_request( &mut self, req: Request<Self::Compact, Self::Context>, ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send

Pushes a constructed request to a storage

Source

fn schedule_request( &mut self, request: Request<Self::Job, Self::Context>, on: i64, ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send

Push a request into the scheduled set

Source

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

Return the number of pending jobs from the queue

Source

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

Fetch a job given an id

Source

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

Update a job details

Source

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

Reschedule a job

Source

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

Returns true if there is no jobs in the storage

Source

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

Vacuum the storage, removes done and killed jobs

Provided Methods§

Source

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

Pushes a job to a storage

Source

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

Push a job with defaults into the scheduled set

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§