#[workflow]Expand description
Marks a function as a durable workflow with automatic crash recovery.
Supports two signatures:
No input — fn(Ctx):
ⓘ
#[durable::workflow]
async fn daily_etl(ctx: Ctx) -> Result<EtlReport, DurableError> {
let data = ctx.step("extract", || async { fetch().await }).await?;
ctx.complete(&data).await?;
Ok(data)
}
// Generated: durable_daily_etl(&db, "my-etl").await?Typed input — fn(Ctx, T) where T: Serialize + DeserializeOwned:
ⓘ
#[derive(Serialize, Deserialize)]
struct IngestInput { crawl_id: String, shard_count: u32 }
#[durable::workflow]
async fn ingest(ctx: Ctx, input: IngestInput) -> Result<(), DurableError> {
for shard in 0..input.shard_count {
ctx.step(&format!("shard-{shard}"), || async {
process_shard(&input.crawl_id, shard).await
}).await?;
}
ctx.complete(&"done").await?;
Ok(())
}
// Generated: durable_ingest(&db, "my-ingest", IngestInput { crawl_id: "CC-2026".into(), shard_count: 72 }).await?
// On crash recovery: input is automatically deserialized and passed to ingest()