Struct apalis_sql::sqlite::SqliteStorage
source · pub struct SqliteStorage<T, C = JsonCodec<String>> { /* private fields */ }Available on crate feature
sqlite only.Expand description
Represents a Storage that persists to Sqlite
Implementations§
source§impl SqliteStorage<()>
impl SqliteStorage<()>
source§impl<T: Serialize + DeserializeOwned> SqliteStorage<T>
impl<T: Serialize + DeserializeOwned> SqliteStorage<T>
sourcepub fn new(pool: SqlitePool) -> Self
pub fn new(pool: SqlitePool) -> Self
Create a new instance
sourcepub fn new_with_config(pool: SqlitePool, config: Config) -> Self
pub fn new_with_config(pool: SqlitePool, config: Config) -> Self
Create a new instance with a custom config
sourcepub async fn keep_alive_at<Service>(
&mut self,
worker_id: &WorkerId,
last_seen: i64,
) -> Result<(), Error>
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
sourcepub fn pool(&self) -> &Pool<Sqlite>
pub fn pool(&self) -> &Pool<Sqlite>
Expose the pool for other functionality, eg custom migrations
sourcepub fn get_config(&self) -> &Config
pub fn get_config(&self) -> &Config
Get the config used by the storage
source§impl<T, C> SqliteStorage<T, C>
impl<T, C> SqliteStorage<T, C>
sourcepub fn codec(&self) -> &PhantomData<C>
pub fn codec(&self) -> &PhantomData<C>
Expose the code used
source§impl<T> SqliteStorage<T>
impl<T> SqliteStorage<T>
sourcepub async fn retry(
&mut self,
worker_id: &WorkerId,
job_id: &TaskId,
) -> Result<(), Error>
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
sourcepub async fn kill(
&mut self,
worker_id: &WorkerId,
job_id: &TaskId,
) -> Result<(), Error>
pub async fn kill( &mut self, worker_id: &WorkerId, job_id: &TaskId, ) -> Result<(), Error>
Kill a job
sourcepub async fn reenqueue_failed(&mut self) -> Result<(), Error>
pub async fn reenqueue_failed(&mut self) -> Result<(), Error>
Add jobs that failed back to the queue if there are still remaining attemps
Trait Implementations§
source§impl<T: Sync + Send, Res: Serialize + Sync> Ack<T, Res> for SqliteStorage<T>
impl<T: Sync + Send, Res: Serialize + Sync> Ack<T, Res> for SqliteStorage<T>
source§type Context = SqlContext
type Context = SqlContext
The data to fetch from context to allow acknowledgement
source§impl<T: Serialize + DeserializeOwned + Sync + Send + Unpin + 'static, Res> Backend<Request<T>, Res> for SqliteStorage<T>
impl<T: Serialize + DeserializeOwned + Sync + Send + Unpin + 'static, Res> Backend<Request<T>, Res> for SqliteStorage<T>
source§impl<T> Clone for SqliteStorage<T>
impl<T> Clone for SqliteStorage<T>
source§impl<T, C> Debug for SqliteStorage<T, C>
impl<T, C> Debug for SqliteStorage<T, C>
source§impl<T, C> Storage for SqliteStorage<T, C>
impl<T, C> Storage for SqliteStorage<T, C>
source§type Identifier = TaskId
type Identifier = TaskId
Jobs must have Ids.
source§async fn push(&mut self, job: Self::Job) -> Result<TaskId, Self::Error>
async fn push(&mut self, job: Self::Job) -> Result<TaskId, Self::Error>
Pushes a job to a storage
source§async fn schedule(
&mut self,
job: Self::Job,
on: i64,
) -> Result<TaskId, Self::Error>
async fn schedule( &mut self, job: Self::Job, on: i64, ) -> Result<TaskId, Self::Error>
Push a job into the scheduled set
source§async fn fetch_by_id(
&mut self,
job_id: &TaskId,
) -> Result<Option<Request<Self::Job>>, Self::Error>
async fn fetch_by_id( &mut self, job_id: &TaskId, ) -> Result<Option<Request<Self::Job>>, Self::Error>
Fetch a job given an id
source§async fn len(&mut self) -> Result<i64, Self::Error>
async fn len(&mut self) -> Result<i64, Self::Error>
Return the number of pending jobs from the queue
source§async fn reschedule(
&mut self,
job: Request<T>,
wait: Duration,
) -> Result<(), Self::Error>
async fn reschedule( &mut self, job: Request<T>, wait: Duration, ) -> Result<(), Self::Error>
Reschedule a job
source§async fn update(&mut self, job: Request<Self::Job>) -> Result<(), Self::Error>
async fn update(&mut self, job: Request<Self::Job>) -> Result<(), Self::Error>
Update a job details
Auto Trait Implementations§
impl<T, C> Freeze for SqliteStorage<T, C>
impl<T, C = JsonCodec<String>> !RefUnwindSafe for SqliteStorage<T, C>
impl<T, C> Send for SqliteStorage<T, C>
impl<T, C> Sync for SqliteStorage<T, C>
impl<T, C> Unpin for SqliteStorage<T, C>
impl<T, C = JsonCodec<String>> !UnwindSafe for SqliteStorage<T, C>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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