Durable workflows in Rust. Write workflows as ordinary async Rust functions, or in the Open Workflow YAML DSL (formerly Serverless Workflow), and run both on one engine. The engine records every step, so a workflow that is interrupted, by a crash, a deploy or a restart, continues where it stopped instead of starting over.
jackdaw is a library first: there is no server to install. Embed the engine in your service, or use the jackdaw
command-line tool to run YAML workflows directly.
| Crate | What it is | Docs |
|---|---|---|
jackdaw-wf |
The library, imported as jackdaw: the engine, the Rust API, the stores and the YAML interpreter |
README, docs.rs |
jackdaw-wf-macros |
#[task], #[workflow] and the other macros, re-exported by jackdaw-wf |
README |
jackdaw-cli |
The jackdaw binary: run, validate and visualize YAML workflows |
README |
All three are released together, at the same version.
- Durable. Each step is journaled. A restarted process resumes its workflows from the journal, and completed steps are not run again.
- Typed. Tasks, workflows, signals, queries and child workflows have typed inputs and outputs, checked by the compiler.
- Plain Rust. Control flow is
if,match, loops and?. The macros name things; they do not define a DSL. - Deterministic by construction. Calls that would break replay, like
SystemTime::now(), are compile errors whose message names the replacement. - One engine for Rust and YAML. They share events and storage, and they call each other: Rust runs YAML workflows, and YAML calls Rust tasks.
- Operational features. Retries, timeouts, heartbeats, caching, named concurrency limits, durable timers, cron
schedules, leases for several engines on one store, retention,
tracingspans andmetrics. - Pluggable storage. Redb (embedded, the default), SQLite and Postgres, or your own store.
- Serve APIs from workflows. Listeners start a workflow for each request to an OpenAPI operation or a gRPC method, with requests checked against the OpenAPI document.
- Testable.
testing::TestEngineruns workflows on a virtual clock and replays each run to check that it is deterministic.
cargo add jackdaw-wf --features cli
cargo add serde --features derive
cargo add tokio --features macros,rt-multi-threadA workflow's input is its configuration: one struct that says everything a run needs. #[derive(Config)] turns it into
command line flags, and the same fields can be read from environment variables and files.
use jackdaw::prelude::*;
use jackdaw::runner::Program;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Config)]
struct Hello {
/// Who to greet
#[serde(default = "world")]
name: String,
}
fn world() -> String {
"World".to_string()
}
// A task does the work. Its result is recorded, so it is not repeated after a restart.
#[task]
async fn greet(name: String) -> Result<String, TaskError> {
Ok(format!("Hello, {name}!"))
}
// A workflow decides which tasks run. It is deterministic, so it can be replayed from its journal.
#[workflow(namespace = "examples", name = "hello", version = "1.0.0")]
struct Hello;
#[workflow_methods]
impl Hello {
#[run]
async fn run(ctx: &mut WorkflowContext<Self>, hello: Hello) -> WorkflowResult<String> {
Ok(ctx.call(Greet, &hello.name).retry(Retry::exponential(3)).await?)
}
}
#[tokio::main]
async fn main() -> Result<std::process::ExitCode, Error> {
let engine = Engine::builder()
.store(Redb::open("jackdaw.redb")?) // without a store, state stays in memory
.task(Greet)
.workflow::<Hello>()
.build()?;
engine.recover().await?; // whatever was running when the last process stopped
// Reads the input, runs the workflow, shows its progress and prints the greeting as JSON.
Ok(Program::<Hello>::new(engine).main().await)
}hello --name Ada # flags
HELLO_NAME=Ada hello # environment
hello --config hello.toml # a toml, json or yaml file; flags override the environment, which overrides files
hello --run-id greeting-1 # a named run: run it again and it is resumed or its result returned, not repeated
hello --helpThe library README has a longer example, and the guide covers tasks, workflows, durability, catalogs, YAML, testing, errors and events.
< 549C div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="cargo install jackdaw-cli --locked # or: cargo binstall jackdaw-cli">cargo install jackdaw-cli --locked # or: cargo binstall jackdaw-cli