pub struct SqliteBackend { /* private fields */ }Expand description
SQLite-backed state store for local development.
Run migrations with SqliteBackend::migrate before first use.
Implementations§
Source§impl SqliteBackend
impl SqliteBackend
Sourcepub async fn connect(database_url: &str) -> Result<Self, Error>
pub async fn connect(database_url: &str) -> Result<Self, Error>
Connect to the SQLite database at database_url and return a backend.
database_url is a SQLx-compatible URL, e.g. sqlite:///path/to/db.sqlite3.
The database file is created automatically if it does not exist.
Sourcepub async fn migrate(&self) -> Result<(), MigrateError>
pub async fn migrate(&self) -> Result<(), MigrateError>
Run embedded migrations against the connected database.
Sourcepub async fn open(
database_url: &str,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub async fn open( database_url: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Convenience: connect and immediately run migrations.
Sourcepub fn for_tenant(&self, tenant_id: TenantId) -> TenantScopedSqliteBackend
pub fn for_tenant(&self, tenant_id: TenantId) -> TenantScopedSqliteBackend
Create a tenant-scoped view of this backend.
All operations on the returned backend are filtered by tenant_id,
ensuring complete data isolation between tenants.
Sourcepub fn pool(&self) -> SqlitePool
pub fn pool(&self) -> SqlitePool
Get a clone of the underlying connection pool.
Trait Implementations§
Source§impl StateBackend for SqliteBackend
impl StateBackend for SqliteBackend
Source§fn store_workflow<'life0, 'async_trait>(
&'life0 self,
def: WorkflowDefinition,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_workflow<'life0, 'async_trait>(
&'life0 self,
def: WorkflowDefinition,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store a compiled workflow IR.
Source§fn get_workflow<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
version: &'life2 str,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkflowDefinition>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_workflow<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
version: &'life2 str,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkflowDefinition>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Load a workflow definition by id and version.
Source§fn create_execution<'life0, 'async_trait>(
&'life0 self,
execution: WorkflowExecution,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_execution<'life0, 'async_trait>(
&'life0 self,
execution: WorkflowExecution,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new workflow execution record.
Source§fn get_execution<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkflowExecution>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_execution<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkflowExecution>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load a workflow execution by id.
Source§fn update_execution_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
status: WorkflowStatus,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_execution_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
status: WorkflowStatus,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update the status of a workflow execution.
Source§fn update_execution_current_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
current_state: &'life2 Value,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update_execution_current_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 ExecutionId,
current_state: &'life2 Value,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update the current_state of a workflow execution (apply state patches).
Source§fn patch_append_array<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn patch_append_array<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append a value to an array field in the execution’s current_state.
Creates the array if it doesn’t exist.
Source§fn list_executions<'life0, 'async_trait>(
&'life0 self,
status: Option<WorkflowStatus>,
limit: u32,
offset: u32,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<WorkflowExecution>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_executions<'life0, 'async_trait>(
&'life0 self,
status: Option<WorkflowStatus>,
limit: u32,
offset: u32,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<WorkflowExecution>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List executions, optionally filtered by status.
Source§fn append_event<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = BackendResult<EventSequence>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_event<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = BackendResult<EventSequence>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Append an event to the event log.
Must be transactional — either fully written or not at all.
Source§fn get_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load all events for an execution, ordered by sequence.
Source§fn get_events_since<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
since_sequence: EventSequence,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_events_since<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
since_sequence: EventSequence,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load events since a given sequence number (exclusive).
Source§fn latest_sequence<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<EventSequence>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn latest_sequence<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<EventSequence>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the latest event sequence for an execution.
Source§fn write_snapshot<'life0, 'async_trait>(
&'life0 self,
snapshot: Snapshot,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_snapshot<'life0, 'async_trait>(
&'life0 self,
snapshot: Snapshot,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Write a snapshot.
Source§fn latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the latest snapshot for an execution.
Source§fn enqueue_work_item<'life0, 'async_trait>(
&'life0 self,
item: WorkItem,
) -> Pin<Box<dyn Future<Output = BackendResult<WorkItemId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn enqueue_work_item<'life0, 'async_trait>(
&'life0 self,
item: WorkItem,
) -> Pin<Box<dyn Future<Output = BackendResult<WorkItemId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Enqueue a work item for execution.
Source§fn claim_work_item<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
worker_id: &'life1 str,
queue_types: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkItem>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn claim_work_item<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
worker_id: &'life1 str,
queue_types: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = BackendResult<Option<WorkItem>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Claim the next available work item for a given queue type.
Returns None if no items are available.
Source§fn renew_lease<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
worker_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn renew_lease<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
worker_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Renew the lease on a claimed work item (heartbeat).
Source§fn complete_work_item<'life0, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_work_item<'life0, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Mark a work item as completed and release the lease.
Source§fn fail_work_item<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
error: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fail_work_item<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
error: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark a work item as failed. The scheduler will decide whether to retry.
Source§fn reclaim_expired_leases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BackendResult<ReclaimResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reclaim_expired_leases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BackendResult<ReclaimResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reclaim work items whose lease has expired (worker crashed or stalled). Read more
Source§fn move_to_dead_letter<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
last_error: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn move_to_dead_letter<'life0, 'life1, 'async_trait>(
&'life0 self,
item_id: WorkItemId,
last_error: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Move a failed work item to the dead-letter queue.
Source§fn create_token<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = BackendResult<(String, ApiToken)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_token<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = BackendResult<(String, ApiToken)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Create a new API token. Returns
(plaintext_token, token_info).
The plaintext token is only returned here; only its hash is stored.Source§fn validate_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<ApiToken>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate_token<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<ApiToken>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate a plaintext API token. Returns the token info if valid and not revoked.
Source§fn create_tenant<'life0, 'async_trait>(
&'life0 self,
_tenant: Tenant,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_tenant<'life0, 'async_trait>(
&'life0 self,
_tenant: Tenant,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new tenant.
Source§fn get_tenant<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 TenantId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<Tenant>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tenant<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 TenantId,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<Tenant>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a tenant by ID.
Source§fn list_tenants<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Tenant>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_tenants<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BackendResult<Vec<Tenant>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all tenants.
Source§fn update_tenant<'life0, 'async_trait>(
&'life0 self,
_tenant: Tenant,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_tenant<'life0, 'async_trait>(
&'life0 self,
_tenant: Tenant,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update tenant metadata (name, status, policy, limits).
Auto Trait Implementations§
impl Freeze for SqliteBackend
impl !RefUnwindSafe for SqliteBackend
impl Send for SqliteBackend
impl Sync for SqliteBackend
impl Unpin for SqliteBackend
impl UnsafeUnpin for SqliteBackend
impl !UnwindSafe for SqliteBackend
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> 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