pub struct SqliteStore { /* private fields */ }Expand description
SQLite-backed Store. Cheap to clone.
Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn open(path: impl AsRef<Path>) -> Result<SqliteStore, StoreError>
pub async fn open(path: impl AsRef<Path>) -> Result<SqliteStore, StoreError>
Open (creating if needed) the database at path with default settings.
Sourcepub async fn open_with(
path: impl AsRef<Path>,
cfg: SqliteStoreConfig,
) -> Result<SqliteStore, StoreError>
pub async fn open_with( path: impl AsRef<Path>, cfg: SqliteStoreConfig, ) -> Result<SqliteStore, StoreError>
Open (creating if needed) the database at path with cfg and apply the schema.
Sourcepub async fn migrate(&self) -> Result<(), StoreError>
pub async fn migrate(&self) -> Result<(), StoreError>
Apply pending schema migrations (idempotent; serialized across processes).
SqliteStore::open already does this.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
The connection pool, for monitoring queries.
Sourcepub fn config(&self) -> &SqliteStoreConfig
pub fn config(&self) -> &SqliteStoreConfig
The configuration this store was opened with.
Sourcepub async fn leadership_lost(&self)
pub async fn leadership_lost(&self)
Resolves once leadership held by this instance is lost (lease taken over or not renewable).
Sourcepub async fn release_leadership(&self)
pub async fn release_leadership(&self)
Give up leadership, letting a standby take over at once.
Sourcepub async fn get_task(
&self,
target: &TaskRef,
) -> Result<Option<TaskRecord>, StoreError>
pub async fn get_task( &self, target: &TaskRef, ) -> Result<Option<TaskRecord>, StoreError>
Look up a task by id, or the newest task with a key.
Sourcepub async fn list_finished(
&self,
pools: &[&str],
statuses: &[TaskStatus],
after: Option<TaskId>,
limit: usize,
) -> Result<Vec<TaskRecord>, StoreError>
pub async fn list_finished( &self, pools: &[&str], statuses: &[TaskStatus], after: Option<TaskId>, limit: usize, ) -> Result<Vec<TaskRecord>, StoreError>
Finished tasks in id order: those in one of pools (any if empty) with one of
statuses (any finished status if empty) and ids above after, at most limit.
Trait Implementations§
Source§impl Clone for SqliteStore
impl Clone for SqliteStore
Source§impl Store<Bytes, Bytes> for SqliteStore
impl Store<Bytes, Bytes> for SqliteStore
Source§fn acquire_leadership<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u16, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn acquire_leadership<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u16, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Block until this instance is the leader; returns the new fencing epoch.
Source§fn release_leadership<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn release_leadership<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Give up leadership (e.g. when startup fails after it was acquired).
Source§fn commit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
epoch: u16,
base: TimeBase,
batch: &'life1 [Mutation<Bytes>],
outputs: &'life2 [(TaskId, &'life3 Bytes)],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn commit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
epoch: u16,
base: TimeBase,
batch: &'life1 [Mutation<Bytes>],
outputs: &'life2 [(TaskId, &'life3 Bytes)],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Durably apply a batch, in order. Must fail with
StoreError::Fenced if epoch is
stale. outputs holds the outputs of tasks that succeed in this batch.Source§fn recover<'life0, 'async_trait>(
&'life0 self,
base: TimeBase,
) -> Pin<Box<dyn Future<Output = Result<Recovered<Bytes>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recover<'life0, 'async_trait>(
&'life0 self,
base: TimeBase,
) -> Pin<Box<dyn Future<Output = Result<Recovered<Bytes>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Load non-terminal tasks, recent terminal statuses and schedules.
Source§fn load_output<'life0, 'async_trait>(
&'life0 self,
id: TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_output<'life0, 'async_trait>(
&'life0 self,
id: TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Output of a task that succeeded earlier, if the store still has it (used for handles
to tasks that finished before they were requested, e.g. duplicate submissions).
Source§impl StoreQueries<Bytes> for SqliteStore
impl StoreQueries<Bytes> for SqliteStore
Source§fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 TaskRef,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 TaskRef,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The task
target refers to: by id, or the newest task with that key.Source§fn prune<'life0, 'async_trait>(
&'life0 self,
older_than: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn prune<'life0, 'async_trait>(
&'life0 self,
older_than: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete finished tasks older than
older_than that no live task depends on; returns
how many were deleted.Source§fn list_finished<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
pools: &'life1 [&'life2 str],
statuses: &'life3 [TaskStatus],
after: Option<TaskId>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn list_finished<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
pools: &'life1 [&'life2 str],
statuses: &'life3 [TaskStatus],
after: Option<TaskId>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Finished tasks in id order: those in one of
pools (any if empty) with one of
statuses (any finished status if empty) and ids above after, at most limit.Auto Trait Implementations§
impl !RefUnwindSafe for SqliteStore
impl !UnwindSafe for SqliteStore
impl Freeze for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
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