Skip to main content

Crate turul_a2a_aws_lambda

Crate turul_a2a_aws_lambda 

Source
Expand description

AWS Lambda adapter for turul-a2a: it feeds Lambda events to the same axum router the binary server uses, so one AgentExecutor runs unchanged behind a Function URL, API Gateway, ALB or SQS.

Use it to deploy an A2A agent as a Lambda function; executor, storage and middleware come from turul-a2a.

§Example

[dependencies]
turul-a2a = "0.2"
turul-a2a-proto = "0.2"
turul-a2a-aws-lambda = "0.2"
async-trait = "0.1"
lambda_runtime = "1"
tokio = { version = "1", features = ["full"] }
use turul_a2a::storage::InMemoryA2aStorage;
use turul_a2a_aws_lambda::LambdaA2aServerBuilder;

#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
    // In-memory storage suits a demo; use a shared backend in production.
    LambdaA2aServerBuilder::new()
        .executor(Echo)
        .storage(InMemoryA2aStorage::new())
        .run()
        .await
}

§Choosing a runner

LambdaA2aServerBuilder::run is the default entry point. Without the sqs feature it is run_http_only; with it, run_http_and_sqs, which accepts either event shape. The named runners are strict and fail on any other shape: run_http_only (Function URL / API Gateway), run_sqs_only and run_http_and_sqs (both sqs). For a third trigger, match on classify_event yourself and pass HTTP events to LambdaA2aHandler::handle_http_event_value. Behind a REST API Gateway stage, set LambdaA2aServerBuilder::strip_path_prefix so the router sees root-rooted paths.

§Lambda behaviour

  • SSE responses are buffered: the task runs, its events are collected, and one response is returned. GET /tasks/{id}:subscribe serves tasks that are not yet terminal and closes on a terminal state or INPUT_REQUIRED.
  • Push-notification delivery cannot rely on work continuing after the response. Recovery is carried by LambdaScheduledRecoveryHandler (required on every backend) and, on DynamoDB, LambdaStreamRecoveryHandler.
  • No cross-instance cancel poller runs. CancelTask writes its marker to the shared backend, but a live executor on a different invocation does not observe it.

§Features

FeatureEnables
sqsSQS-backed durable executor and the SQS runners
dynamodbturul-a2a’s DynamoDB backend

§Where next

Structs§

AuthorizerMapping
Mapping configuration for Lambda authorizer context.
LambdaA2aHandler
Lambda handler wrapping the axum Router.
LambdaA2aServerBuilder
Builder for Lambda A2A handler.
LambdaAuthorizerMiddleware
Middleware that reads trusted authorizer context from x-authorizer-* headers.
LambdaScheduledRecoveryConfig
Configuration for a scheduled-recovery sweep.
LambdaScheduledRecoveryHandler
Handler for scheduled push-recovery ticks.
LambdaScheduledRecoveryResponse
Summary returned from a single scheduled-recovery tick.
LambdaStreamRecoveryHandler
Handler for DynamoDB Stream events on a2a_push_pending_dispatches.
NoStreamingLayer
Tower Layer that rejects streaming paths on Lambda.

Enums§

LambdaEvent
Coarse Lambda event-shape discriminator returned by classify_event.

Functions§

axum_to_lambda_response
Convert an axum response to a Lambda HTTP response.
classify_event
Classify a raw Lambda event JSON shape.
handle_maintenance_trigger
Run one retention-maintenance sweep, invoked by an EventBridge Scheduler rule.
lambda_to_axum_request
Convert a Lambda HTTP request to an axum request.