pub struct PostgresStore { /* private fields */ }Expand description
Clone is derived because the underlying PgPool is itself Clone
(it’s Arc<PoolInner> internally) — cloning the store hands back a
new wrapper around the same connection pool. Required so engine
composition (EngineState<S>) can derive Clone and pass through
axum with_state.
Implementations§
Source§impl PostgresStore
impl PostgresStore
pub async fn new(url: &str) -> Result<Self>
Sourcepub async fn from_pool(pool: PgPool) -> Result<Self>
pub async fn from_pool(pool: PgPool) -> Result<Self>
Build a store from an existing pool. Runs migrations on the target database. Useful when the engine owns the pool (shared with other modules) and hands a clone to the workflow module, or for tests that point many stores at different databases in the same Postgres server.
Sourcepub fn pool(&self) -> &PgPool
pub fn pool(&self) -> &PgPool
Expose the underlying pool (used by the engine to build a
PgEngineEventBus that shares the same connection pool).
Sourcepub async fn try_acquire_leader_lock(&self) -> Result<bool>
pub async fn try_acquire_leader_lock(&self) -> Result<bool>
Try to acquire pg_advisory_lock for leader election. Returns true if this instance is the leader (scheduler should run).
Trait Implementations§
Source§impl Clone for PostgresStore
impl Clone for PostgresStore
Source§fn clone(&self) -> PostgresStore
fn clone(&self) -> PostgresStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl WorkflowStore for PostgresStore
impl WorkflowStore for PostgresStore
async fn create_namespace(&self, name: &str) -> Result<()>
async fn list_namespaces(&self) -> Result<Vec<NamespaceRecord>>
async fn delete_namespace(&self, name: &str) -> Result<bool>
async fn get_namespace_stats(&self, namespace: &str) -> Result<NamespaceStats>
async fn create_workflow(&self, wf: &WorkflowRecord) -> Result<()>
async fn get_workflow(&self, id: &str) -> Result<Option<WorkflowRecord>>
async fn list_workflows( &self, namespace: &str, status: Option<WorkflowStatus>, workflow_type: Option<&str>, search_attrs_filter: Option<&str>, limit: i64, offset: i64, ) -> Result<Vec<WorkflowRecord>>
async fn update_workflow_status( &self, id: &str, status: WorkflowStatus, result: Option<&str>, error: Option<&str>, ) -> Result<()>
async fn claim_workflow(&self, id: &str, worker_id: &str) -> Result<bool>
Source§async fn mark_workflow_dispatchable(&self, workflow_id: &str) -> Result<()>
async fn mark_workflow_dispatchable(&self, workflow_id: &str) -> Result<()>
claim_workflow_task.Source§async fn claim_workflow_task(
&self,
task_queue: &str,
worker_id: &str,
) -> Result<Option<WorkflowRecord>>
async fn claim_workflow_task( &self, task_queue: &str, worker_id: &str, ) -> Result<Option<WorkflowRecord>>
dispatch_claimed_by and dispatch_last_heartbeat, clears
needs_dispatch. Returns the workflow record or None if nothing
is available.Source§async fn release_workflow_task(
&self,
workflow_id: &str,
worker_id: &str,
) -> Result<()>
async fn release_workflow_task( &self, workflow_id: &str, worker_id: &str, ) -> Result<()>
dispatch_claimed_by
matches the calling worker.Source§async fn release_stale_dispatch_leases(
&self,
now: f64,
timeout_secs: f64,
) -> Result<u64>
async fn release_stale_dispatch_leases( &self, now: f64, timeout_secs: f64, ) -> Result<u64>
timeout_secs. Used by the engine’s background poller to
recover from worker crashes. Returns how many leases were released
(each becomes claimable again, with needs_dispatch=true).async fn append_event(&self, ev: &WorkflowEvent) -> Result<i64>
async fn list_events(&self, workflow_id: &str) -> Result<Vec<WorkflowEvent>>
async fn get_event_count(&self, workflow_id: &str) -> Result<i64>
async fn create_activity(&self, act: &WorkflowActivity) -> Result<i64>
Source§async fn get_activity(&self, id: i64) -> Result<Option<WorkflowActivity>>
async fn get_activity(&self, id: i64) -> Result<Option<WorkflowActivity>>
Source§async fn get_activity_by_workflow_seq(
&self,
workflow_id: &str,
seq: i32,
) -> Result<Option<WorkflowActivity>>
async fn get_activity_by_workflow_seq( &self, workflow_id: &str, seq: i32, ) -> Result<Option<WorkflowActivity>>
async fn claim_activity( &self, task_queue: &str, worker_id: &str, ) -> Result<Option<WorkflowActivity>>
Source§async fn requeue_activity_for_retry(
&self,
id: i64,
next_attempt: i32,
next_scheduled_at: f64,
) -> Result<()>
async fn requeue_activity_for_retry( &self, id: i64, next_attempt: i32, next_scheduled_at: f64, ) -> Result<()>
attempt,
and sets scheduled_at = now + backoff so the next claim_activity
won’t pick it up before the backoff elapses.async fn complete_activity( &self, id: i64, result: Option<&str>, error: Option<&str>, failed: bool, ) -> Result<()>
async fn heartbeat_activity( &self, id: i64, _details: Option<&str>, ) -> Result<()>
async fn get_timed_out_activities( &self, now: f64, ) -> Result<Vec<WorkflowActivity>>
async fn create_timer(&self, timer: &WorkflowTimer) -> Result<i64>
Source§async fn cancel_pending_activities(&self, workflow_id: &str) -> Result<u64>
async fn cancel_pending_activities(&self, workflow_id: &str) -> Result<u64>
Source§async fn cancel_pending_timers(&self, workflow_id: &str) -> Result<u64>
async fn cancel_pending_timers(&self, workflow_id: &str) -> Result<u64>
Source§async fn get_timer_by_workflow_seq(
&self,
workflow_id: &str,
seq: i32,
) -> Result<Option<WorkflowTimer>>
async fn get_timer_by_workflow_seq( &self, workflow_id: &str, seq: i32, ) -> Result<Option<WorkflowTimer>>
async fn fire_due_timers(&self, now: f64) -> Result<Vec<WorkflowTimer>>
async fn send_signal(&self, sig: &WorkflowSignal) -> Result<i64>
async fn consume_signals( &self, workflow_id: &str, name: &str, ) -> Result<Vec<WorkflowSignal>>
async fn create_schedule(&self, sched: &WorkflowSchedule) -> Result<()>
async fn get_schedule( &self, namespace: &str, name: &str, ) -> Result<Option<WorkflowSchedule>>
async fn list_schedules(&self, namespace: &str) -> Result<Vec<WorkflowSchedule>>
async fn update_schedule_last_run( &self, namespace: &str, name: &str, last_run_at: f64, next_run_at: f64, workflow_id: &str, ) -> Result<()>
async fn delete_schedule(&self, namespace: &str, name: &str) -> Result<bool>
Source§async fn list_archivable_workflows(
&self,
cutoff: f64,
limit: i64,
) -> Result<Vec<WorkflowRecord>>
async fn list_archivable_workflows( &self, cutoff: f64, limit: i64, ) -> Result<Vec<WorkflowRecord>>
completed_at is older than
cutoff and which haven’t been archived yet. Used by the optional
S3 archival background task to batch candidates.Source§async fn mark_archived_and_purge(
&self,
workflow_id: &str,
archive_uri: &str,
archived_at: f64,
) -> Result<()>
async fn mark_archived_and_purge( &self, workflow_id: &str, archive_uri: &str, archived_at: f64, ) -> Result<()>
archived_at + archive_uri)
and purge its events, activities, timers, signals, and snapshots.
The workflow record itself is preserved so GET /workflows/{id}
still resolves with an archive pointer.Source§async fn upsert_search_attributes(
&self,
workflow_id: &str,
patch_json: &str,
) -> Result<()>
async fn upsert_search_attributes( &self, workflow_id: &str, patch_json: &str, ) -> Result<()>
search_attributes.
Keys in the patch overwrite existing keys; keys already present but
not in the patch are preserved. If the current column is NULL, the
patch becomes the new value.Source§async fn update_schedule(
&self,
namespace: &str,
name: &str,
patch: &SchedulePatch,
) -> Result<Option<WorkflowSchedule>>
async fn update_schedule( &self, namespace: &str, name: &str, patch: &SchedulePatch, ) -> Result<Option<WorkflowSchedule>>
patch are updated; the rest keep their current values. Returns
the updated record, or None if the schedule doesn’t exist. Read moreSource§async fn set_schedule_paused(
&self,
namespace: &str,
name: &str,
paused: bool,
) -> Result<Option<WorkflowSchedule>>
async fn set_schedule_paused( &self, namespace: &str, name: &str, paused: bool, ) -> Result<Option<WorkflowSchedule>>
paused flag. Returns the updated record, or
None if the schedule doesn’t exist. Read moreasync fn register_worker(&self, w: &WorkflowWorker) -> Result<()>
async fn heartbeat_worker(&self, id: &str, now: f64) -> Result<()>
async fn list_workers(&self, namespace: &str) -> Result<Vec<WorkflowWorker>>
async fn remove_dead_workers(&self, cutoff: f64) -> Result<Vec<String>>
async fn list_child_workflows( &self, parent_id: &str, ) -> Result<Vec<WorkflowRecord>>
async fn create_snapshot( &self, workflow_id: &str, event_seq: i32, state_json: &str, ) -> Result<()>
async fn get_latest_snapshot( &self, workflow_id: &str, ) -> Result<Option<WorkflowSnapshot>>
async fn get_queue_stats(&self, namespace: &str) -> Result<Vec<QueueStats>>
Auto Trait Implementations§
impl Freeze for PostgresStore
impl !RefUnwindSafe for PostgresStore
impl Send for PostgresStore
impl Sync for PostgresStore
impl Unpin for PostgresStore
impl UnsafeUnpin for PostgresStore
impl !UnwindSafe for PostgresStore
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
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>
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>
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