#[durable_execution]Expand description
Attribute macro that transforms an async function into a durable Lambda handler.
This macro wraps your async function to integrate with AWS Lambda’s durable execution service. It handles:
- Parsing
DurableExecutionInvocationInputfrom the Lambda event - Creating
ExecutionStateandDurableContextfor the handler - Processing results, errors, and suspend signals
- Returning
DurableExecutionInvocationOutputwith appropriate status
§Function Signature
The decorated function must have the following signature:
ⓘ
async fn handler_name(event: EventType, ctx: DurableContext) -> Result<ResultType, DurableError>Where:
EventTypemust implementserde::DeserializeResultTypemust implementserde::Serialize
§Example
ⓘ
use durable_execution_sdk::{durable_execution, DurableContext, DurableError};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct MyEvent {
order_id: String,
}
#[derive(Serialize)]
struct MyResult {
status: String,
}
#[durable_execution]
async fn my_handler(event: MyEvent, ctx: DurableContext) -> Result<MyResult, DurableError> {
// Your workflow logic here
let result = ctx.step(|_| Ok("processed".to_string()), None).await?;
Ok(MyResult { status: result })
}§Generated Code
The macro generates two functions:
- An inner async function (
__<name>_inner) containing the user’s original logic - A Lambda handler wrapper that accepts
LambdaEvent<DurableExecutionInvocationInput>and delegates torun_durable_handlerwith the inner function
All runtime concerns (event deserialization, state management, context creation,
result/error/suspend handling) are encapsulated in run_durable_handler.