pub struct LambdaA2aHandler { /* private fields */ }Expand description
Lambda handler wrapping the axum Router.
Implementations§
Source§impl LambdaA2aHandler
impl LambdaA2aHandler
pub fn builder() -> LambdaA2aServerBuilder
Sourcepub async fn cancel_idle_tasks(&self) -> Result<IdleSweep, A2aStorageError>
pub async fn cancel_idle_tasks(&self) -> Result<IdleSweep, A2aStorageError>
Cancel tasks left waiting on their client for longer than the
runtime configuration’s idle_task_timeout; see
turul_a2a::server::A2aServerBuilder::idle_task_timeout. With no
timeout set this does nothing. Run by
LambdaScheduledRecoveryHandler::with_idle_task_sweep.
Sourcepub async fn handle(&self, event: Request) -> Result<Response<Body>, Error>
pub async fn handle(&self, event: Request) -> Result<Response<Body>, Error>
Handle a Lambda HTTP request. An executor still running when the response is ready (work after it reported its result) is aborted before this returns, so no storage request it started outlives the invocation.
Sourcepub async fn handle_http_event_value(
&self,
value: Value,
) -> Result<Value, Error>
pub async fn handle_http_event_value( &self, value: Value, ) -> Result<Value, Error>
Handle a raw Lambda HTTP event delivered as serde_json::Value
and return a response envelope matching the inbound event
shape:
Inbound shape detected by lambda_http::LambdaRequest | Response envelope |
|---|---|
API Gateway v1 (REST) — top-level httpMethod + path | ApiGatewayProxyResponse |
API Gateway v2 / Function URL — requestContext.http | ApiGatewayV2httpResponse |
ALB target group — requestContext.elb | AlbTargetGroupResponse |
| WebSocket / unrecognised | Err(...) |
Mismatching envelopes — most commonly a v2 response sent in
response to a v1 invocation — cause API Gateway to return
502 Bad Gateway regardless of the body, because the response
fails the gateway’s contract validation. This method ensures
symmetry: response shape is always picked from the inbound
shape, never hardcoded.
This is the framework’s canonical HTTP envelope conversion
primitive — useful when a single Lambda function routes among
HTTP and one or more non-framework triggers (EventBridge,
DynamoDB streams, custom invoke) and the adopter drives
lambda_runtime::run with serde_json::Value directly.
Handles the LambdaRequest deserialization, the text-vs-base64
content-type detection, and the response envelope rebuild.
Body encoding: text for text/*, application/json,
application/xml, application/javascript, any +json / +xml
structured-syntax suffix (RFC 6839, e.g. application/a2a+json),
or anything with charset=; base64 otherwise.
Path-prefix stripping (see
LambdaA2aServerBuilder::strip_path_prefix) is applied
because dispatch flows through Self::handle. Adopters who
only serve HTTP should continue to use Self::run_http_only
or LambdaA2aServerBuilder::run; this entry point exists for
composition with adopter-owned third triggers.
Source§impl LambdaA2aHandler
impl LambdaA2aHandler
Sourcepub async fn run_http_only(self) -> Result<(), Error>
pub async fn run_http_only(self) -> Result<(), Error>
Run this handler as a pure HTTP Lambda. Strict: any non-HTTP
event shape (SQS, DynamoDB stream, scheduler, …) causes
lambda_http::run to return a deserialization error on
invocation.
Appropriate for Lambdas whose only trigger is a Function URL, API Gateway, or ALB. The request Lambda in the two-Lambda durable-executor topology is the canonical caller.