Struct apalis::sqlite::SqliteStorage

source ·
pub struct SqliteStorage<T> { /* private fields */ }
Available on crate feature sqlite only.
Expand description

Represents a Storage that persists to Sqlite

Implementations§

source§

impl SqliteStorage<()>

source

pub async fn setup(pool: &Pool<Sqlite>) -> Result<(), Error>

Perform migrations for storage

source

pub fn migrations() -> Migrator

Get sqlite migrations without running them

source§

impl<T> SqliteStorage<T>

source

pub fn new(pool: Pool<Sqlite>) -> SqliteStorage<T>

Construct a new Storage from a pool

source

pub fn new_with_config(pool: Pool<Sqlite>, config: Config) -> SqliteStorage<T>

Create a new instance with a custom config

source

pub async fn keep_alive_at<Service>( &mut self, worker_id: &WorkerId, last_seen: i64 ) -> Result<(), Error>

Keeps a storage notified that the worker is still alive manually

source

pub fn pool(&self) -> &Pool<Sqlite>

Expose the pool for other functionality, eg custom migrations

source§

impl<T> SqliteStorage<T>

source

pub async fn retry( &mut self, worker_id: &WorkerId, job_id: &TaskId ) -> Result<(), Error>

Puts the job instantly back into the queue Another [Worker] may consume

source

pub async fn kill( &mut self, worker_id: &WorkerId, job_id: &TaskId ) -> Result<(), Error>

Kill a job

source

pub async fn reenqueue_failed(&self) -> Result<(), Error>
where T: Job,

Add jobs that failed back to the queue if there are still remaining attemps

source

pub async fn reenqueue_orphaned(&self, timeout: i64) -> Result<(), Error>
where T: Job,

Add jobs that workers have disappeared to the queue

Trait Implementations§

source§

impl<T> Ack<T> for SqliteStorage<T>
where T: Sync,

§

type Acknowledger = TaskId

The data to fetch from context to allow acknowledgement
§

type Error = Error

The error returned by the ack
source§

async fn ack( &self, worker_id: &WorkerId, task_id: &<SqliteStorage<T> as Ack<T>>::Acknowledger ) -> Result<(), Error>

Acknowledges successful processing of the given request
source§

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

§

type Stream = BackendStream<Pin<Box<dyn Stream<Item = Result<Option<Request<T>>, Error>> + Send>>>

The stream to be produced by the backend
§

type Layer = AckLayer<SqliteStorage<T>, T>

Returns the final decoration of layers
source§

fn common_layer( &self, worker_id: WorkerId ) -> <SqliteStorage<T> as Backend<Request<T>>>::Layer

Allows the backend to decorate the service with Layer
source§

fn poll( self, worker: WorkerId ) -> Poller<<SqliteStorage<T> as Backend<Request<T>>>::Stream>

Returns a poller that is ready for streaming
source§

impl<T> Clone for SqliteStorage<T>

source§

fn clone(&self) -> SqliteStorage<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for SqliteStorage<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

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

§

type Job = T

The type of job that can be persisted
§

type Error = Error

The error produced by the storage
§

type Identifier = TaskId

Jobs must have Ids.
source§

async fn push( &mut self, job: <SqliteStorage<T> as Storage>::Job ) -> Result<TaskId, <SqliteStorage<T> as Storage>::Error>

Pushes a job to a storage
source§

async fn schedule( &mut self, job: <SqliteStorage<T> as Storage>::Job, on: i64 ) -> Result<TaskId, <SqliteStorage<T> as Storage>::Error>

Push a job into the scheduled set
source§

async fn fetch_by_id( &self, job_id: &TaskId ) -> Result<Option<Request<<SqliteStorage<T> as Storage>::Job>>, <SqliteStorage<T> as Storage>::Error>

Fetch a job given an id
source§

async fn len(&self) -> Result<i64, <SqliteStorage<T> as Storage>::Error>

Return the number of pending jobs from the queue
source§

async fn reschedule( &mut self, job: Request<T>, wait: Duration ) -> Result<(), <SqliteStorage<T> as Storage>::Error>

Reschedule a job
source§

async fn update( &self, job: Request<<SqliteStorage<T> as Storage>::Job> ) -> Result<(), <SqliteStorage<T> as Storage>::Error>

Update a job details
source§

async fn is_empty(&self) -> Result<bool, <SqliteStorage<T> as Storage>::Error>

Returns true if there is no jobs in the storage
source§

async fn vacuum(&self) -> Result<usize, Error>

Vacuum the storage, removes done and killed jobs

Auto Trait Implementations§

§

impl<T> Freeze for SqliteStorage<T>

§

impl<T> !RefUnwindSafe for SqliteStorage<T>

§

impl<T> Send for SqliteStorage<T>
where T: Send,

§

impl<T> Sync for SqliteStorage<T>
where T: Sync,

§

impl<T> Unpin for SqliteStorage<T>
where T: Unpin,

§

impl<T> !UnwindSafe for SqliteStorage<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more