durable-lambda-builder
Builder-pattern API style for AWS Lambda durable execution workflows.
Overview
durable-lambda-builder provides the most configurable API style for the durable-rust SDK. Use the builder pattern to configure tracing subscribers and error handlers before starting the Lambda runtime.
Call durable_lambda_builder::handler(closure) to create a DurableHandlerBuilder, optionally configure it with .with_tracing() and .with_error_handler(), then call .run() to start.
API Style Comparison
All four API styles produce identical runtime behavior. They differ only in ergonomics:
| Crate | Style | Boilerplate | Configuration | Best for |
|---|---|---|---|---|
durable-lambda-closure |
Closure-native (recommended) | Minimal | None | Getting started, most use cases |
durable-lambda-macro |
Proc-macro | Lowest | None | Zero-boilerplate preference |
durable-lambda-trait |
Trait-based | Moderate | Via struct fields | Complex handlers with shared state |
durable-lambda-builder |
Builder-pattern | Moderate | .with_tracing(), .with_error_handler() |
Production deployments needing hooks |
Choose durable-lambda-builder when you need runtime configuration hooks -- tracing subscribers for observability, error handlers for logging/transformation, or both.
Features
DurableHandlerBuilderwith fluent configuration API.with_tracing(subscriber)to install a tracing subscriber before Lambda runtime starts.with_error_handler(fn)to intercept and transform errors before they propagateBuilderContextwrappingDurableContextwith all 8 durable operationsdurable_lambda_builder::handler(closure).run()entry pointpreludemodule re-exporting all types for single-line imports- Full access to all durable operations: Step, Wait, Callback, Invoke, Parallel, Map, Child Context, Logging
Getting Started
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= "1"
For tracing support, also add:
[]
= "0.1"
= "0.3"
Usage
Basic Handler (no configuration)
use *;
async
With Tracing
Install a tracing subscriber before the Lambda runtime starts. The subscriber is set as the global default via tracing::subscriber::set_global_default:
use *;
use fmt;
async
With Error Handler
Intercept, log, or transform errors before they propagate to the Lambda runtime:
use *;
use DurableError;
async
Full Production Configuration
Chain all builder methods for a fully configured production handler:
use *;
use DurableError;
use fmt;
async
All Operations
The BuilderContext exposes the same 8 operations as every other API style:
use *;
async
Prelude
Import everything you need with a single line:
use *;
This re-exports BuilderContext, DurableHandlerBuilder, DurableContext, DurableError, StepOptions, ExecutionMode, and all other commonly used types.
Testing
Test your handler logic with durable-lambda-testing -- no AWS credentials needed:
use *;
async
API Reference
| Type | Description |
|---|---|
DurableHandlerBuilder |
Builder with .with_tracing(), .with_error_handler(), .run() |
BuilderContext |
Wrapper context with all 8 durable operations |
handler(closure) |
Creates a new DurableHandlerBuilder |
Re-exported from durable-lambda-core:
| Type | Description |
|---|---|
DurableContext |
Core context type (used in parallel/map/child_context callbacks) |
DurableError |
SDK infrastructure error type |
StepOptions |
Step configuration (retries, backoff, timeout, retry_if) |
ExecutionMode |
Replaying or Executing |
Full API documentation: docs.rs/durable-lambda-builder
License
Licensed under either of MIT or Apache-2.0 at your option.