#[workflow]Expand description
Marks a function as a durable workflow.
Workflows are multi-step processes that:
- Survive server restarts
- Handle failures with compensation
- Track progress and state
- Can run for hours, days, or longer
§Attributes
version = 1- Workflow version (increment for breaking changes)timeout = "24h"- Maximum workflow execution timedeprecated- Mark as deprecated
§Example
ⓘ
#[forge::workflow]
#[version = 1]
pub async fn user_onboarding(
ctx: &WorkflowContext,
input: OnboardingInput,
) -> Result<OnboardingResult> {
let user = ctx.step("create_user")
.run(|| ctx.mutate(create_user, input.clone()))
.compensate(|user| ctx.mutate(delete_user, user.id))
.await?;
ctx.step("send_welcome")
.run(|| send_email(&user.email))
.optional()
.await;
Ok(OnboardingResult { user })
}