pub async fn run_durable_handler<E, R, Fut, F>(
lambda_event: LambdaEvent<DurableExecutionInvocationInput>,
handler: F,
) -> Result<DurableExecutionInvocationOutput, Error>where
E: DeserializeOwned,
R: Serialize,
Fut: Future<Output = Result<R, DurableError>>,
F: FnOnce(E, DurableContext) -> Fut,Expand description
Runs a durable execution handler within the Lambda runtime.
This is the core runtime function that the #[durable_execution] macro delegates to.
It handles the full lifecycle:
- Extract the user’s event from the Lambda input
- Set up
ExecutionState, checkpoint batcher, andDurableContext - Call the user’s handler
- Process the result (serialize, checkpoint large results, map errors)
- Clean up (drain batcher, drop state)
§Type Parameters
E: The user’s event type (must implementDeserializeOwned)R: The user’s result type (must implementSerialize)Fut: The future returned by the handlerF: The handler function
§Example
ⓘ
use durable_execution_sdk::runtime::run_durable_handler;
// Called automatically by #[durable_execution], but can be used directly:
pub async fn my_handler(
event: LambdaEvent<DurableExecutionInvocationInput>,
) -> Result<DurableExecutionInvocationOutput, lambda_runtime::Error> {
run_durable_handler(event, |event: MyEvent, ctx| async move {
let result = ctx.step(|_| Ok(42), None).await?;
Ok(MyResult { value: result })
}).await
}