Skip to main content

Crate sayiir_core

Crate sayiir_core 

Source
Expand description

Core types and traits for the Sayiir durable workflow engine.

This crate defines the foundational abstractions that every other sayiir-* crate builds on. It is intentionally runtime-agnostic — no persistence, no execution strategy, just pure workflow modelling.

§Key Abstractions

Type / TraitPurpose
Workflow / SerializableWorkflowThe continuation tree that describes what to execute
WorkflowBuilderFluent builder for assembling sequential, forked, and joined pipelines
CoreTaskTrait implemented by every task (input → output, with metadata)
CodecTrait for pluggable serialization (JSON, rkyv, …)
WorkflowContextPer-execution context carrying the codec, workflow ID, and user metadata
WorkflowSnapshotCheckpoint of in-flight execution state (completed tasks + outputs)
TaskRegistryName → factory map used for deserializing workflows across process boundaries

§Architecture

sayiir-core          (this crate — types & traits only)
  ↑
sayiir-persistence   (SnapshotStore, SignalStore, TaskClaimStore)
  ↑
sayiir-runtime       (CheckpointingRunner, PooledWorker, execution loop)
  ↑
sayiir-macros        (#[task], workflow! — optional convenience)

§Quick Example

use sayiir_core::prelude::*;
use std::sync::Arc;

// Create a context (codec + workflow ID)
// (Codec is generic — bring your own or use sayiir-runtime's JsonCodec / RkyvCodec)
let ctx = WorkflowContext::new("order-pipeline", Arc::new(my_codec), Arc::new(()));

// Build a workflow: validate → charge
let wf = WorkflowBuilder::new(ctx)
    .then("validate", |order: String| async move { Ok(order) })
    .then("charge", |order: String| async move { Ok(42u64) })
    .build()?;

For the proc-macro experience (#[task] + workflow!), see sayiir-macros.

Modules§

branch_results
Named branch results — the outputs of parallel fork branches.
builder
codec
context
error
Error types for sayiir-core.
prelude
Common imports for workflow authors.
registry
Task registry for serializable workflows.
snapshot
Workflow snapshot structures for checkpoint/restore functionality.
task
task_claim
Task claiming mechanism for multi-node collaboration.
workflow

Macros§

sayiir_ctx
Macro to access the workflow context from within a task.