pub struct SqliteStore { /* private fields */ }Expand description
Clone is derived because the underlying SqlitePool is itself
Clone (it’s Arc<PoolInner> internally) — cloning the store hands
back a new wrapper around the same connection pool. The
instance_id is per-store identity (heartbeat row tag), shared
across clones so all clones look like the same instance to
engine.lock.
Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn new(url: &str) -> Result<Self>
pub async fn new(url: &str) -> Result<Self>
Open a SqliteStore at url. Provisions an in-memory engine +
workflow ATTACH automatically — convenient for tests and
embedders that don’t need persistent module isolation. Production
deployments use SqliteStore::from_attached_pool with the
engine-controlled pool that ATTACHes to <data_dir>/*.db files.
Sourcepub async fn from_attached_pool(pool: SqlitePool) -> Result<Self>
pub async fn from_attached_pool(pool: SqlitePool) -> Result<Self>
Construct from an externally-managed pool that already has the
engine and workflow databases ATTACHed. The engine binary
uses this — its pool’s after_connect hook ATTACHes the
per-module file paths from [backend].data_dir.
Sourcepub async fn from_pool(pool: SqlitePool) -> Result<Self>
pub async fn from_pool(pool: SqlitePool) -> Result<Self>
Backward-compat alias for SqliteStore::from_attached_pool.
Older call sites passed a bare pool from SqlitePool::connect();
after v0.1.2 the pool must already have the engine + workflow
databases attached. The implementation is identical, kept under
the legacy name so external embedders don’t break on upgrade.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Expose the underlying pool (used by the engine to build an
SqliteEngineEventBus that shares the same connection).
Sourcepub async fn acquire_engine_lock(&self) -> Result<()>
pub async fn acquire_engine_lock(&self) -> Result<()>
Acquire the single-instance engine lock. Returns an error if another instance is already running.
Sourcepub async fn refresh_engine_lock(&self) -> Result<()>
pub async fn refresh_engine_lock(&self) -> Result<()>
Refresh the engine lock heartbeat. Called periodically by the engine.
Sourcepub async fn release_engine_lock(&self) -> Result<()>
pub async fn release_engine_lock(&self) -> Result<()>
Release the engine lock on shutdown.
Sourcepub fn spawn_lock_heartbeat(self: &Arc<Self>)
pub fn spawn_lock_heartbeat(self: &Arc<Self>)
Start background task to keep the lock alive.
Trait Implementations§
Source§impl Clone for SqliteStore
impl Clone for SqliteStore
Source§fn clone(&self) -> SqliteStore
fn clone(&self) -> SqliteStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl WorkflowStore for SqliteStore
impl WorkflowStore for SqliteStore
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 SqliteStore
impl !RefUnwindSafe for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
impl !UnwindSafe 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
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