Resonate Rust SDK
The Resonate Rust SDK lets you build reliable, distributed applications using Rust's async/await model. Built on tokio, it gives you durable execution with automatic recovery, idempotency, and distributed coordination — without the infrastructure headache.
Resonate is a durable execution engine.
Write your business logic as normal async Rust functions, annotate them with #[resonate_sdk::function], and Resonate handles retries, recovery, and replay.
If your process crashes mid-workflow, execution resumes from the last checkpoint — not from the beginning.
Links
Installation
Or add to your Cargo.toml directly:
[]
= "0.1"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
To track the latest development version, use a git dependency:
[]
= { = "https://github.com/resonatehq/resonate-sdk-rust", = "main" }
Quick example
use *;
use ;
// A workflow function — receives &Context for durable sub-task orchestration.
async
// A leaf function — pure computation, no Context needed.
async
async
Run a server with resonate dev (install via brew install resonatehq/tap/resonate), then cargo run.
Parallel execution
Use .spawn() to fan out durable tasks in parallel:
async
If the process crashes after h1 completes but before h2 finishes, only h2 and h3 re-execute on recovery. h1's result is replayed from the durable log.
API overview
Entry point
| Method | Description |
|---|---|
Resonate::new(config) |
Connect to a Resonate Server |
Resonate::local() |
In-memory mode (no server needed) |
Client APIs (Ephemeral World)
| Method | Description |
|---|---|
resonate.register(func) |
Register a durable function |
resonate.run(id, func, args) |
Execute a function locally |
resonate.rpc(id, func_name, args) |
Execute a function remotely (by name) |
resonate.schedule(name, cron, func_name, args) |
Schedule a cron-based execution |
resonate.get(id) |
Get a handle to an existing execution |
resonate.stop() |
Graceful shutdown |
resonate.promises |
Sub-client for raw promise operations |
resonate.schedules |
Sub-client for schedule management |
Context APIs (Durable World)
| Method | Description |
|---|---|
ctx.run(func, args) |
Invoke a child function locally |
ctx.rpc::<T>(func_name, args) |
Invoke a child function remotely |
ctx.sleep(duration) |
Durable sleep (survives restarts) |
All builders support .await (sequential) or .spawn().await (parallel, returns a handle).
Builder options
All builders support:
.timeout(Duration)— execution timeout.target(&str)— target worker group
Client-side builders (resonate.run(), resonate.rpc()) additionally support:
.version(u32)— version tag.tags(HashMap<String, String>)— metadata tags
Function annotation
#[resonate_sdk::function] detects the function kind from the first parameter:
| First parameter | Kind | Description |
|---|---|---|
&Context |
Workflow | Can orchestrate sub-tasks via ctx.run(), ctx.rpc(), ctx.sleep() |
&Info |
Leaf with metadata | Read-only access to execution metadata |
| (anything else) | Pure leaf | Stateless computation |
Environment variables
| Variable | Description | Default |
|---|---|---|
RESONATE_URL |
Full server URL | (local mode) |
RESONATE_HOST |
Server hostname | (unset) |
RESONATE_PORT |
Server port | 8001 |
RESONATE_TOKEN |
JWT auth token | (unset) |
RESONATE_PREFIX |
Promise ID prefix | (empty) |
Constructor arguments take precedence over environment variables. If no URL is configured, the SDK runs in local mode (in-memory, no server required).
License
Apache-2.0