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> SqliteStorage<T>
impl<T> 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
Source§impl<T, C> SqliteStorage<T, C>
impl<T, C> SqliteStorage<T, C>
Sourcepub async fn keep_alive_at(
&mut self,
worker: &Worker<Context>,
last_seen: i64,
) -> Result<(), Error>
pub async fn keep_alive_at( &mut self, worker: &Worker<Context>, 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, C> SqliteStorage<T, C>
impl<T, C> SqliteStorage<T, C>
Trait Implementations§
Source§impl<T, C> Backend<Request<T, SqlContext>> for SqliteStorage<T, C>
impl<T, C> Backend<Request<T, SqlContext>> for SqliteStorage<T, C>
Source§type Stream = BackendStream<Pin<Box<dyn Stream<Item = Result<Option<Request<T, SqlContext>>, Error>> + Send>>>
type Stream = BackendStream<Pin<Box<dyn Stream<Item = Result<Option<Request<T, SqlContext>>, Error>> + Send>>>
The stream to be produced by the backend
Source§type Layer = AckLayer<SqliteStorage<T, C>, T, SqlContext, C>
type Layer = AckLayer<SqliteStorage<T, C>, T, SqlContext, C>
Returns the final decoration of layers
Source§impl<J: 'static + Serialize + DeserializeOwned + Unpin + Send + Sync> BackendExpose<J> for SqliteStorage<J, JsonCodec<String>>
impl<J: 'static + Serialize + DeserializeOwned + Unpin + Send + Sync> BackendExpose<J> for SqliteStorage<J, JsonCodec<String>>
Source§async fn stats(&self) -> Result<Stat, Self::Error>
async fn stats(&self) -> Result<Stat, Self::Error>
Returns the counts of jobs in different states
Source§async fn list_jobs(
&self,
status: &State,
page: i32,
) -> Result<Vec<Self::Request>, Self::Error>
async fn list_jobs( &self, status: &State, page: i32, ) -> Result<Vec<Self::Request>, Self::Error>
Fetch jobs persisted in a backend
Source§async fn list_workers(&self) -> Result<Vec<Worker<WorkerState>>, Self::Error>
async fn list_workers(&self) -> Result<Vec<Worker<WorkerState>>, Self::Error>
List all Workers that are working on a backend
Source§impl<T, C> Clone for SqliteStorage<T, C>
impl<T, C> Clone for SqliteStorage<T, C>
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 Context = SqlContext
type Context = SqlContext
This is the type that storages store as the metadata related to a job
Source§async fn push_request(
&mut self,
job: Request<Self::Job, SqlContext>,
) -> Result<Parts<SqlContext>, Self::Error>
async fn push_request( &mut self, job: Request<Self::Job, SqlContext>, ) -> Result<Parts<SqlContext>, Self::Error>
Pushes a constructed request to a storage
Source§async fn push_raw_request(
&mut self,
job: Request<Self::Compact, SqlContext>,
) -> Result<Parts<SqlContext>, Self::Error>
async fn push_raw_request( &mut self, job: Request<Self::Compact, SqlContext>, ) -> Result<Parts<SqlContext>, Self::Error>
Pushes a constructed request to a storage
Source§async fn schedule_request(
&mut self,
req: Request<Self::Job, SqlContext>,
on: i64,
) -> Result<Parts<SqlContext>, Self::Error>
async fn schedule_request( &mut self, req: Request<Self::Job, SqlContext>, on: i64, ) -> Result<Parts<SqlContext>, Self::Error>
Push a request into the scheduled set
Source§async fn fetch_by_id(
&mut self,
job_id: &TaskId,
) -> Result<Option<Request<Self::Job, SqlContext>>, Self::Error>
async fn fetch_by_id( &mut self, job_id: &TaskId, ) -> Result<Option<Request<Self::Job, SqlContext>>, 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, SqlContext>,
wait: Duration,
) -> Result<(), Self::Error>
async fn reschedule( &mut self, job: Request<T, SqlContext>, wait: Duration, ) -> Result<(), Self::Error>
Reschedule a job
Source§async fn update(
&mut self,
job: Request<Self::Job, SqlContext>,
) -> Result<(), Self::Error>
async fn update( &mut self, job: Request<Self::Job, SqlContext>, ) -> Result<(), Self::Error>
Update a job details
Source§async fn is_empty(&mut self) -> Result<bool, Self::Error>
async fn is_empty(&mut self) -> Result<bool, Self::Error>
Returns true if there is no jobs in the storage
Source§async fn vacuum(&mut self) -> Result<usize, Error>
async fn vacuum(&mut self) -> Result<usize, Error>
Vacuum the storage, removes done and killed jobs
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§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