sayiir-macros 0.1.0-alpha.5

Procedural macros for the Sayiir durable workflow engine
Documentation

sayiir-macros

Procedural macros for the Sayiir durable workflow engine.

Overview

Provides two macros that eliminate boilerplate when defining workflows:

  • #[task] — Transforms an async function into a CoreTask struct with automatic registration, metadata, and dependency injection.
  • workflow! — Builds a workflow pipeline with a concise DSL that desugars to WorkflowBuilder method calls.

#[task]

use sayiir_macros::task;

#[task(timeout = "30s", retries = 3, backoff = "100ms")]
async fn charge(order: Order, #[inject] stripe: Arc<Stripe>) -> Result<Receipt, BoxError> {
    stripe.charge(&order).await
}

Attributes

Attribute Description
id = "…" Override task ID (default: function name)
display_name = "…" Human-readable name
description = "…" Task description
timeout = "30s" Task timeout (ms, s, m, h suffixes)
retries = 3 Maximum retry count
backoff = "100ms" Initial retry delay
backoff_multiplier = 2.0 Exponential multiplier (default: 2.0)
tags = "io" Categorization tags (repeatable)

Parameters

  • Exactly one non-#[inject] parameter: the task input type
  • Zero or more #[inject] parameters: dependency-injected fields

Generated Code

The macro generates a PascalCase struct (e.g., fn chargestruct Charge) with new(), task_id(), metadata(), register(), and a CoreTask trait implementation. The original function is preserved for direct use and testing.

workflow!

let workflow = workflow!("order-process", JsonCodec, registry,
    validate(order: Order) { validate_order(order) }
    => charge
    => send_email || update_inventory
    => finalize
);

Syntax

Element Meaning
task_name Reference to a #[task]-generated struct
name(param: Type) { expr } Inline task
step || step Parallel fork (branches)
delay "5s" Durable delay
=> Sequential chain (or join after ||)

Documentation

Full API docs are available on docs.rs.

License

MIT