Expand description
§Durable Workflow Rust SDK
durable-workflow is the first-party Rust client and worker SDK for
Durable Workflow. Rust applications can start
and inspect workflows, run workflow and activity handlers, and exchange typed
Avro values with PHP, Python, and Rust workers through one durable runtime.
Use the SDK with a self-hosted Durable Workflow Server or a managed Durable Workflow Cloud namespace. Your workers remain ordinary Rust processes and scale independently from the runtime.
§Install
Rust 1.86 or newer is required.
cargo add durable-workflowApplications using Tokio entry points should also enable the Tokio features they need:
cargo add tokio --features macros,rt-multi-thread§Run the example
examples/hello_world.rs is a complete typed
workflow and activity example. It starts a workflow, runs two activities,
demonstrates retry and failure handling, waits for completion, and prints the
result.
Start a bootstrapped self-hosted Server, then run the example from this repository:
DURABLE_WORKFLOW_SERVER_URL=http://127.0.0.1:8080 \
DURABLE_WORKFLOW_TOKEN=dev-token \
cargo run --example hello_worldPass the Server origin without a trailing /api. TASK_QUEUE changes the
default rust-workers queue, and GREETING_NAME changes the example input.
For a provisioned Cloud namespace, use the exact runtime URL and the separate client and worker credentials shown in Cloud:
DURABLE_WORKFLOW_RUNTIME_URL=https://cloud.durable-workflow.com/api/runtime/v1/namespaces/your-namespace-id \
DURABLE_WORKFLOW_RUNTIME_NAMESPACE=your.namespace \
DURABLE_WORKFLOW_CLIENT_TOKEN=your-client-token \
DURABLE_WORKFLOW_WORKER_TOKEN=your-worker-token \
cargo run --example hello_worldThe namespace runtime URL is already complete. Do not append another /api.
§Core API
Clientstarts, signals, queries, updates, cancels, terminates, describes, and awaits workflow executions.Workerregisters workflow, activity, signal, query, and update handlers and long-polls task queues.WorkflowContextprovides durable activities, timers, conditions, child workflows, side effects, version markers, parallel operations, selection, sagas, message streams, memo, search attributes, and continue-as-new.- Typed registration and result helpers preserve Serde request and result types over the fixed Avro Value protocol.
- Activity options cover retries, start-to-close, schedule-to-start, schedule-to-close, heartbeat timeouts, cancellation, and heartbeats.
The SDK writes Avro payloads only. The fixed recursive Value schema preserves nulls, booleans, signed 64-bit integers, finite doubles, bytes, UTF-8 strings, lists, and string-keyed maps across official SDKs without customer-managed schemas or a registry.
§Examples
| Example | Demonstrates |
|---|---|
hello_world.rs | Typed worker, workflow, activities, retries, and completion |
activity_options.rs | Activity retry and timeout policies |
condition_search_attributes.rs | Durable conditions and typed search attributes |
continue_as_new.rs | Bounded histories and continue-as-new |
parallel_saga.rs | Deterministic parallel work and saga compensation |
§Documentation
- Rust SDK landing page
- Generated API reference
- Rust SDK guide
- Self-hosted Server guide
- Cloud early access
§Compatibility
The crate publishes its supported Server and worker-protocol ranges in
[package.metadata.durable-workflow] in Cargo.toml. Runtime
capability manifests, not matching package version strings, determine protocol
compatibility. Stable releases follow semantic versioning.
§Development
cargo fmt --all --check
cargo test --all-targets --all-features
cargo doc --all-features --no-deps
cargo packageReplay and codec defects require a minimal regression fixture. See
CONTRIBUTING.md for the corpus rules.
§License
Durable Workflow Rust SDK is released under the MIT License.
Macros§
- json
- Construct a
serde_json::Valuefrom a JSON literal. - wait_
condition - Create a durable condition wait whose predicate definition is fingerprinted from its inline Rust tokens.
Structs§
- Activity
Call - Activity
Context - Activity
Failure - A stable, machine-readable terminal activity failure.
- Activity
Heartbeat Response - Activity
Options - Options recorded atomically on one deterministic
schedule_activitycommand. - Activity
Options Error - A machine-readable activity-options validation failure.
- Activity
Retry Policy - Durable server-side retry policy for one activity execution.
- Activity
Task - Activity
Task Rejection - A worker-side activity settlement or heartbeat rejected by durable state.
- Cancel
Durable Operation Call - Future returned by
DurableOperationHandle::cancel. - Child
Workflow Avro Result - Lossless successful child result for fixed Avro Value workflows.
- Child
Workflow Call - Future returned by
WorkflowContext::start_child_workflow. - Child
Workflow Failure - A stable, machine-readable child workflow failure delivered to its parent.
- Child
Workflow Options - Options recorded with a child-workflow command.
- Child
Workflow Result - A successful child result together with its durable parent-child identity.
- Child
Workflow Retry Policy - Durable retry policy for one child workflow invocation.
- Client
- Client
Builder - Condition
Wait Call - Future returned by
WorkflowContext::wait_condition. - Condition
Wait Options - Stable identity and optional durable timeout for a condition wait.
- Continue
AsNew Options - Optional routing overrides for a continue-as-new transition.
- Continue
AsNew Options Error - A stable validation error raised before a continue-as-new command is emitted.
- Durable
Operation Await Call - Future returned by
DurableOperationHandle::await_result. - Durable
Operation Cancelled - Typed result of explicitly awaiting a cancelled non-winning operation.
- Durable
Operation Handle - Stable reference to one member of a durable selection group.
- History
Event - Message
Stream - Message
Stream Message - Parallel
Call - Future returned by
WorkflowContext::parallel. - Parallel
Completion - One successful leaf retained when another parallel member failed.
- Parallel
Failure - A deterministic join failed after some siblings had already completed.
- Parallel
Group Error - Stable validation error returned before an invalid group emits commands.
- Parallel
Group Metadata - Stable identity for one enclosing deterministic parallel group.
- Payload
Envelope - Poll
Activity Task Response - Poll
Query Task Response - Poll
Workflow Task Response - Protocol
Failure - A stable failure returned when a server rejects an SDK protocol version.
- Query
Context - Immutable state supplied to a registered query handler.
- Query
Failure - A stable, machine-readable workflow query or query-task settlement failure.
- Query
Signal - One decoded signal in the committed workflow-history snapshot.
- Query
Task - An ephemeral server-routed query task.
- Register
Worker Response - Replay
Failure - A stable, machine-readable failure raised when workflow code no longer reconstructs the durable command stream recorded in history.
- Saga
- Workflow-local deterministic saga compensation helper.
- Saga
Compensation Failure - A forward saga failure followed by a terminal compensation failure.
- Search
Attribute Update - Validated typed workflow-side search-attribute mutation.
- Select
Call - Future returned by
WorkflowContext::select. - Selection
Result - The one winner committed for a durable selection group.
- Signal
Call - Timer
Call - Future returned by
WorkflowContext::sleep. - Uuid
- A Universally Unique Identifier (UUID).
- Worker
- Worker
Deregistration Envelope - Result of gracefully removing a worker-plane registration.
- Worker
Heartbeat Observation - Worker
Retry Policy - Bounded retry policy for worker poll acquisition and worker heartbeats.
- Workflow
Cancellation Requested - Cooperative workflow cancellation observed at an author-controlled point.
- Workflow
Command Options - Optional structured fields for a cancellation or termination request.
- Workflow
Command Rejection - A stable rejection returned by instance- or selected-run lifecycle commands.
- Workflow
Command Result - The accepted, machine-readable result of a lifecycle command.
- Workflow
Context - Workflow
Description - Workflow
Handle - Workflow
History Budget - Public history-budget information attached to the current workflow task.
- Workflow
Identity - The identity of one durable workflow execution.
- Workflow
Instance - Typed local state owned by one deterministic workflow invocation.
- Workflow
Result Options - Workflow
Start Options - Server-enforced timeout policy for a workflow start.
- Workflow
Stream Append Item - One item for direct or replay-safe append.
- Workflow
Stream Append Result - Durable acceptance and deduplication outcome for an append request.
- Workflow
Stream Description - Lifecycle and backlog metadata for one run-scoped Workflow Stream.
- Workflow
Stream Item - One durable item at its stable zero-based offset.
- Workflow
Stream Page - One bounded at-least-once subscription page.
- Workflow
Task - Workflow
Terminal Outcome - A typed terminal workflow outcome with durable identity and failure metadata.
Enums§
- Activity
Backoff - Backoff intervals for one durable activity retry policy.
- Activity
Failure Kind - Stable terminal categories returned when an awaited activity does not succeed.
- Activity
Options Error Kind - Stable validation categories for
ActivityOptions. - Avro
Value - Native adapter for the fixed language-neutral Avro Value schema.
- Child
Workflow Failure Kind - Stable terminal categories returned when an awaited child does not succeed.
- Condition
Wait Options Error - Validation failure for a durable condition-wait definition.
- Condition
Wait Result - Unambiguous terminal result of a durable condition wait.
- Error
- Handler
Kind - The registered handler family reported by
Error::HandlerType. - Handler
Value Kind - Whether a typed handler failed to adapt its input or result.
- Parallel
Avro Result - Lossless fixed-Avro counterpart to
ParallelResult. - Parallel
Operation - A deferred durable leaf or nested group for
WorkflowContext::parallel. - Parallel
Result - One input-ordered result returned by
WorkflowContext::parallel. - Parent
Close Policy - Server behavior when a parent closes while its child is still open.
- Search
Attribute Update Error - Validation failure for a typed workflow search-attribute update.
- Search
Attribute Value - One public typed search-attribute value.
- Selection
Key - Stable user-facing identity for one member of a durable selection group.
- Value
- Represents any valid JSON value.
- Worker
Poll Outcome - Stable classification for worker poll responses.
- Workflow
Command Kind - The lifecycle command sent to a workflow execution.
- Workflow
Terminal Kind - Stable terminal categories returned by
WorkflowHandle::result.
Constants§
- AVRO_
VALUE_ SCHEMA_ FINGERPRINT - AVRO_
VALUE_ SCHEMA_ FINGERPRINT_ HEX - AVRO_
VALUE_ SCHEMA_ JSON - Canonical Avro Value schema packaged with the crate and parsed by the runtime.
- CONDITION_
WAIT_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that defines external durable condition waits.
- CONDITION_
WAIT_ OCCURRENCE_ IDENTITY_ CAPABILITY - Worker-registration capability for authored condition-wait occurrence identity.
- CONDITION_
WAIT_ OCCURRENCE_ IDENTITY_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that preserves authored condition-wait occurrences.
- CONTROL_
PLANE_ VERSION - DEFAULT_
CODEC - DURABLE_
SELECTION_ CAPABILITY - Worker-registration capability for persisted first-completion selection.
- DURABLE_
SELECTION_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that defines durable selection groups.
- MEMO_
UPSERTS_ CAPABILITY - Worker-registration capability for portable memo upserts.
- MEMO_
UPSERT_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that defines portable memo upserts.
- MESSAGE_
STREAMS_ CAPABILITY - Worker-registration capability for durable named input streams.
- MESSAGE_
STREAMS_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - MESSAGE_
STREAM_ CURSOR_ SCHEMA - MESSAGE_
STREAM_ MAX_ BATCH - MESSAGE_
STREAM_ SCHEMA - MESSAGE_
STREAM_ SIGNAL - PORTABLE_
WORKER_ AFFINITY_ MINIMUM_ PROTOCOL_ VERSION - First additive worker protocol that defines portable worker-affinity features.
- QUERY_
TASKS_ CAPABILITY - Worker-registration capability for server-routed read-only queries.
- QUERY_
TASK_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that defines query-task transport.
- SDK_
VERSION - SEARCH_
ATTRIBUTE_ UPDATE_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that defines typed search-attribute upserts.
- TYPED_
SEARCH_ ATTRIBUTES_ CAPABILITY - Worker-registration capability for canonical typed search attributes.
- TYPED_
SEARCH_ ATTRIBUTES_ MINIMUM_ WORKER_ PROTOCOL_ VERSION - First additive worker protocol that preserves declared search-attribute types.
- WORKER_
PROTOCOL_ VERSION - WORKFLOW_
UPDATES_ CAPABILITY - Worker-registration capability for synchronous workflow updates.
Functions§
- decode_
avro_ value - decode_
payload - encode_
avro_ value - encode_
payload - portable_
worker_ affinity_ capability_ manifest - Truthful service-worker manifest for features this SDK currently refuses.
- worker_
protocol_ supports_ message_ streams