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 aCoreTaskstruct with automatic registration, metadata, and dependency injection.workflow!— Builds a workflow pipeline with a concise DSL that desugars toWorkflowBuildermethod calls.
#[task]
use task;
async
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 charge → struct 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!;
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