wfe-sqlite (1.4.0)
Installation
[registry]
default = "gitea"
[registries.gitea]
index = "sparse+ " # Sparse index
# index = " " # Git
[net]
git-fetch-with-cli = truecargo add wfe-sqlite@1.4.0About this package
wfe-sqlite
SQLite persistence provider for the WFE workflow engine.
What it does
Implements the full PersistenceProvider trait (workflows, events, subscriptions, scheduled commands, execution errors) backed by SQLite via sqlx. Supports both in-memory and file-based databases. Tables and indexes are created automatically on startup -- no migrations to run.
Quick start
use wfe_sqlite::SqlitePersistenceProvider;
// In-memory (good for tests and single-process deployments)
let provider = SqlitePersistenceProvider::new(":memory:").await?;
// File-based (persistent across restarts)
let provider = SqlitePersistenceProvider::new("sqlite:///tmp/wfe.db").await?;
Wire it into the WFE host as your persistence layer:
let host = WorkflowHost::new(provider);
API
| Type | Trait |
|---|---|
SqlitePersistenceProvider |
PersistenceProvider, WorkflowRepository, EventRepository, SubscriptionRepository, ScheduledCommandRepository |
Key methods come from the traits -- create_new_workflow, persist_workflow, get_runnable_instances, create_event, schedule_command, and so on. See wfe-core for the full trait definitions.
Configuration
The constructor takes a standard SQLite connection string:
| Value | Behavior |
|---|---|
":memory:" |
In-memory database, single connection, lost on drop |
"sqlite:///path/to/db" |
File-backed, WAL journal mode, up to 4 connections |
WAL mode and foreign keys are enabled automatically. For in-memory mode, the pool is capped at 1 connection to avoid separate database instances.
Schema
Six tables are created in the default schema:
workflows-- workflow instance state and metadataexecution_pointers-- step execution state, linked to workflows via foreign keyevents-- published events pending processingevent_subscriptions-- active event subscriptions with CAS-style token lockingscheduled_commands-- deferred commands with dedup on(command_name, data)execution_errors-- error log for failed step executions
Testing
No external dependencies required. Tests run against :memory::
cargo test -p wfe-sqlite
License
MIT
Dependencies
| ID | Version |
|---|---|
| async-trait | ^0.1 |
| chrono | ^0.4 |
| serde | ^1 |
| serde_json | ^1 |
| sqlx | ^0.8 |
| thiserror | ^2 |
| tokio | ^1 |
| tracing | ^0.1 |
| uuid | ^1 |
| wfe-core | ^1.4.0 |
| pretty_assertions | ^1 |
| rstest | ^0.23 |
| tokio | ^1 |
| wfe-core | ^1.4.0 |