Expand description
Workflow runtime for executing durable workflows.
This crate provides the execution engine that drives sayiir_core workflows
to completion. It re-exports the core crate, persistence layer, and proc-macros
so most users only need a single dependency:
[dependencies]
sayiir-runtime = "0.1"§Execution Strategies
| Scenario | Use |
|---|---|
| Single server, crash recovery needed | CheckpointingRunner |
| Multiple workers, horizontal scaling | PooledWorker |
| Simple in-memory execution | InProcessRunner |
§Quick Example
use sayiir_runtime::{CheckpointingRunner, WorkflowRunner, workflow, task};
use sayiir_runtime::persistence::InMemoryBackend;
let backend = InMemoryBackend::new();
let runner = CheckpointingRunner::new(backend);
// Run a workflow with automatic checkpointing
// let status = runner.run(&workflow, "instance-123", input).await?;§Re-exports
This crate re-exports key items for convenience:
sayiir_core— viasayiir_runtime::persistence(throughsayiir_persistence)sayiir_persistence— aspersistencetaskandworkflow!— fromsayiir-macrostask_context!— context macro fromsayiir-core
§Cargo Features
| Feature | Default | Description |
|---|---|---|
json | yes | JSON serialization codec (serde_json) |
rkyv | yes | Zero-copy binary codec (rkyv) |
macros | yes | Proc-macro re-exports (#[task], workflow!) from sayiir-macros |
otel | no | OpenTelemetry integration — W3C trace context propagation across workers, OTLP span export, and trace_context::init_tracing / trace_context::shutdown_tracing helpers |
At least one of json or rkyv must be enabled (enforced at compile time).
Enable otel in your bindings or application to get distributed trace
propagation via the trace_parent field on snapshots, and a ready-made
subscriber setup controlled by OTEL_EXPORTER_OTLP_ENDPOINT,
OTEL_SERVICE_NAME, and RUST_LOG environment variables.
For the full README with architecture diagrams and detailed configuration, see the crate README.
Re-exports§
pub use error::RuntimeError;pub use execution::PrepareRunOutcome;pub use execution::ResumeOutcome;pub use execution::check_existing_instance;pub use execution::execute_continuation_async;pub use execution::execute_continuation_sync;pub use execution::execute_continuation_with_checkpointing;pub use execution::finalize_execution;pub use execution::prepare_resume;pub use execution::prepare_run;pub use execution::serialize_branch_results;pub use worker::ExternalTaskExecutor;pub use worker::ExternalWorkflow;pub use worker::PooledWorker;pub use worker::PooledWorkerBuilder;pub use worker::WorkerHandle;pub use worker::WorkflowIndex;pub use worker::WorkflowRegistry;pub use sayiir_persistence as persistence;
Modules§
- error
- Typed error for the sayiir runtime layer.
- execution
- Shared workflow execution logic.
- prelude
- Convenience re-exports for common usage.
- serialization
- Serialization codecs for workflow snapshots.
- trace_
context otel - W3C trace context propagation and OpenTelemetry subscriber setup.
- worker
- Pooled worker for distributed, multi-worker workflow execution.
Macros§
- task_
context - Macro to access the task execution context from within a task.
- workflow
macros - Builds a workflow pipeline with a concise DSL.
Structs§
- Checkpointing
Runner - A single-process workflow runner with checkpointing for crash recovery.
- InProcess
Runner - A workflow runner that executes workflows in-process.
- Workflow
Client - A client for submitting and controlling workflow instances.
Enums§
- Conflict
Policy - Policy controlling what happens when [
run()] is called with aninstance_idthat already has a persisted snapshot.
Traits§
- Branch
Key - A routing key for conditional branching.
- Workflow
RunExt - Extension trait providing convenience methods on
Workflow. - Workflow
Runner - A trait for executing workflows.
Attribute Macros§
- task
macros - Transforms an async function into a
CoreTaskimplementation.
Derive Macros§
- Branch
Key macros - Derives
BranchKeyfor a fieldless enum.