Skip to main content

LambdaA2aServerBuilder

Struct LambdaA2aServerBuilder 

Source
pub struct LambdaA2aServerBuilder { /* private fields */ }
Expand description

Builder for Lambda A2A handler.

Use .storage(my_storage) to supply a single backend implementing all storage traits. All four storage traits must share the same backend so streaming, push delivery, and cross-instance cancellation coordinate correctly.

For push-notification delivery, wire .storage() with a backend that implements A2aPushDeliveryStore (all four first-party backends do). The atomic store must also opt in via with_push_dispatch_enabled(true); the builder rejects configurations where the flag and the delivery store disagree.

Implementations§

Source§

impl LambdaA2aServerBuilder

Source

pub fn new() -> Self

Source

pub fn strip_path_prefix(self, prefix: impl Into<String>) -> Self

Configure an HTTP path prefix to strip before the A2A router sees the request. Needed when Lambda sits behind an API Gateway whose stage + resource tree is forwarded into the function (e.g. REST API AWS_PROXY integrations surface /stage/agent/message:send where the A2A router expects /message:send).

The prefix must start with / and must not end with / (unless it is exactly /, which is a no-op). Segment boundaries are respected — a prefix of /dev will not strip /devs/.... Paths that do not start with the prefix pass through unchanged (the router will 404 on a genuinely unknown path, which is the correct failure mode). Applies to both LambdaA2aHandler::run_http_only and [LambdaA2aHandler::run_http_and_sqs]. SQS events are unaffected.

Source

pub fn with_durable_executor(self, queue: Arc<dyn DurableExecutorQueue>) -> Self

Wire a durable executor queue. When set, the return_immediately = true path in core_send_message enqueues a turul_a2a::durable_executor::QueuedExecutorJob on this queue instead of spawning the executor locally, and the capability flag RuntimeConfig::supports_return_immediately is turned back on as an implementation detail — the capability cannot be claimed without supplying the queue.

Adopters should typically reach for the SQS-specific helper [Self::with_sqs_return_immediately] instead; this generic method exists so adopters can inject in-memory fakes for tests or provide non-SQS transports (Kinesis, Step Functions task token, self-invoke, etc.).

Source

pub fn executor(self, exec: impl AgentExecutor + 'static) -> Self

Source

pub fn storage<S>(self, storage: S) -> Self

Set all storage from a single backend instance.

This is the preferred method — a single struct implementing all storage traits guarantees the same-backend requirement AND ensures the cancellation supervisor reads the same backend the cancel marker is written to. A mismatch here (e.g., DynamoDB task storage + in-memory cancellation supervisor) silently breaks cross-instance cancellation.

errata: .storage() wires storage traits only. It does not auto-register the storage as a push-delivery store, even if the backend happens to implement A2aPushDeliveryStore. To opt in to push delivery, call Self::push_delivery_store explicitly and call with_push_dispatch_enabled(true) on the storage instance before passing it here. Non-push deployments need neither.

Source

pub fn task_storage(self, s: impl A2aTaskStorage + 'static) -> Self

Set task storage individually. Must be paired with event_store/atomic_store AND cancellation_supervisor() for same-backend compliance.

Source

pub fn push_storage(self, s: impl A2aPushNotificationStorage + 'static) -> Self

Set push notification storage individually.

Source

pub fn event_store(self, s: impl A2aEventStore + 'static) -> Self

Set event store individually. Must match task_storage backend.

Source

pub fn atomic_store(self, s: impl A2aAtomicStore + 'static) -> Self

Set atomic store individually. Must match task_storage backend.

Source

pub fn cancellation_supervisor( self, s: impl A2aCancellationSupervisor + 'static, ) -> Self

Set the cancellation supervisor individually. Must match task_storage backend — otherwise :cancel writes the marker to one backend and the supervisor reads from another, silently breaking cross-instance cancellation. Prefer .storage() for unified wiring. Consumed by core_cancel_task.

Source

pub fn push_delivery_store( self, store: impl A2aPushDeliveryStore + 'static, ) -> Self

Set the push delivery store individually.

Prefer .storage() for unified wiring. The delivery store MUST be on the same backend as .task_storage(...) — the builder rejects mismatches. Passing a delivery store also requires the atomic store to have opted in via with_push_dispatch_enabled(true) .

Source

pub fn runtime_config(self, cfg: RuntimeConfig) -> Self

Override the runtime configuration (timeouts, retry budgets, push tuning). Defaults to RuntimeConfig::default(). The builder validates push settings (claim expiry vs retry horizon, ) when .push_delivery_store(...) is wired.

Source

pub fn middleware(self, mw: Arc<dyn A2aMiddleware>) -> Self

Source

pub fn build(self) -> Result<LambdaA2aHandler, A2aError>

Source§

impl LambdaA2aServerBuilder

Source

pub async fn run(self) -> Result<(), Error>

Build and run in one call. Sugar for self.build()?.run().await. Hides the handler from the adopter — use .build() + handler.run_*() instead when the handler is needed for unit tests, custom middleware, or an explicit topology runner.

Trait Implementations§

Source§

impl Default for LambdaA2aServerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,