pub struct PgStore { /* private fields */ }Expand description
PostgreSQL-backed Store. Cheap to clone.
Implementations§
Source§impl PgStore
impl PgStore
Sourcepub async fn connect(url: &str) -> Result<PgStore, StoreError>
pub async fn connect(url: &str) -> Result<PgStore, StoreError>
Connect with default settings and apply the schema.
Sourcepub async fn connect_with(
url: &str,
cfg: PgStoreConfig,
) -> Result<PgStore, StoreError>
pub async fn connect_with( url: &str, cfg: PgStoreConfig, ) -> Result<PgStore, StoreError>
Connect 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 instances that use
the same schema). PgStore::connect already does this.
Sourcepub fn config(&self) -> &PgStoreConfig
pub fn config(&self) -> &PgStoreConfig
The configuration this store was opened with.
Sourcepub fn leader_lock(&self) -> (i32, i32)
pub fn leader_lock(&self) -> (i32, i32)
The two keys of the advisory lock held by the leader (pg_locks.classid, objid),
for monitoring.
Sourcepub async fn leadership_lost(&self)
pub async fn leadership_lost(&self)
Resolves once leadership held by this instance is lost (lock session gone).
Sourcepub async fn release_leadership(&self)
pub async fn release_leadership(&self)
Give up leadership (releases the advisory lock).
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 key (the most recent task with that 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 Store<Bytes, Bytes> for PgStore
impl Store<Bytes, Bytes> for PgStore
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 PgStore
impl StoreQueries<Bytes> for PgStore
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 PgStore
impl !UnwindSafe for PgStore
impl Freeze for PgStore
impl Send for PgStore
impl Sync for PgStore
impl Unpin for PgStore
impl UnsafeUnpin for PgStore
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