Skip to main content

Crate sayiir_runtime

Crate sayiir_runtime 

Source
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

ScenarioUse
Single server, crash recovery neededCheckpointingRunner
Multiple workers, horizontal scalingPooledWorker
Simple in-memory executionInProcessRunner

§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:

§Cargo Features

FeatureDefaultDescription
jsonyesJSON serialization codec (serde_json)
rkyvyesZero-copy binary codec (rkyv)
macrosyesProc-macro re-exports (#[task], workflow!) from sayiir-macros
otelnoOpenTelemetry 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_contextotel
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.
workflowmacros
Builds a workflow pipeline with a concise DSL.

Structs§

CheckpointingRunner
A single-process workflow runner with checkpointing for crash recovery.
InProcessRunner
A workflow runner that executes workflows in-process.
WorkflowClient
A client for submitting and controlling workflow instances.

Enums§

ConflictPolicy
Policy controlling what happens when [run()] is called with an instance_id that already has a persisted snapshot.

Traits§

BranchKey
A routing key for conditional branching.
WorkflowRunExt
Extension trait providing convenience methods on Workflow.
WorkflowRunner
A trait for executing workflows.

Attribute Macros§

taskmacros
Transforms an async function into a CoreTask implementation.

Derive Macros§

BranchKeymacros
Derives BranchKey for a fieldless enum.