1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Proc-macro approach for durable Lambda handlers.
//!
//! Provides the `#[durable_execution]` attribute macro (FR32).
//!
//! # Usage
//!
//! Annotate an async handler function with `#[durable_execution]` to generate
//! all Lambda runtime boilerplate. The macro creates a `main()` function that
//! wires up AWS config, Lambda client, `RealBackend`, and `lambda_runtime`.
//!
//! ```ignore
//! use durable_lambda_macro::durable_execution;
//! use durable_lambda_core::context::DurableContext;
//! use durable_lambda_core::error::DurableError;
//!
//! #[durable_execution]
//! async fn handler(event: serde_json::Value, mut ctx: DurableContext) -> Result<serde_json::Value, DurableError> {
//! Ok(event)
//! }
//! ```
use TokenStream;
use parse_macro_input;
/// Attribute macro that transforms an async handler into a complete durable Lambda binary.
///
/// The annotated function must:
/// - Be `async`
/// - Have exactly 2 parameters: `(event: serde_json::Value, ctx: DurableContext)`
/// - Return `Result<serde_json::Value, DurableError>`
///
/// The macro preserves the original function and generates a `#[tokio::main] async fn main()`
/// that sets up the Lambda runtime, AWS backend, and event parsing — mirroring the
/// `#[tokio::main]` ergonomic pattern.