Skip to main content

RequestHandlerBuilder

Struct RequestHandlerBuilder 

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

Fluent builder for RequestHandler.

§Required

  • executor: Any AgentExecutor implementation (passed as a concrete type; the builder erases it to Arc<dyn AgentExecutor> during build).

§Optional (with defaults)

  • task_store: defaults to InMemoryTaskStore.
  • push_config_store: defaults to InMemoryPushConfigStore.
  • push_sender: defaults to None.
  • interceptors: defaults to an empty chain.
  • agent_card: defaults to None.

Implementations§

Source§

impl RequestHandlerBuilder

Source

pub fn new(executor: impl AgentExecutor) -> RequestHandlerBuilder

Creates a new builder with the given executor.

The executor is type-erased to Arc<dyn AgentExecutor>.

Source

pub fn with_task_store( self, store: impl TaskStore + 'static, ) -> RequestHandlerBuilder

Sets a custom task store.

Source

pub const fn with_task_store_config( self, config: TaskStoreConfig, ) -> RequestHandlerBuilder

Configures the default InMemoryTaskStore with custom TTL and capacity settings.

This is ignored if a custom task store is set via with_task_store.

Source

pub fn with_push_config_store( self, store: impl PushConfigStore + 'static, ) -> RequestHandlerBuilder

Sets a custom push configuration store.

Source

pub fn with_push_sender( self, sender: impl PushSender + 'static, ) -> RequestHandlerBuilder

Sets a push notification sender.

Source

pub fn with_interceptor( self, interceptor: impl ServerInterceptor + 'static, ) -> RequestHandlerBuilder

Adds a server interceptor to the chain.

Source

pub const fn with_executor_timeout( self, timeout: Duration, ) -> RequestHandlerBuilder

Sets a timeout for executor execution.

If the executor does not complete within this duration, the task is marked as failed with a timeout error.

Source

pub fn with_agent_card(self, card: AgentCard) -> RequestHandlerBuilder

Sets the agent card for discovery responses.

Source

pub const fn with_event_queue_capacity( self, capacity: usize, ) -> RequestHandlerBuilder

Sets the event queue channel capacity for streaming.

Defaults to 64 items. Higher values allow more events to be buffered before backpressure is applied.

Source

pub const fn with_max_event_size( self, max_event_size: usize, ) -> RequestHandlerBuilder

Sets the maximum serialized event size in bytes.

Events exceeding this size are rejected to prevent OOM conditions. Defaults to 16 MiB.

Source

pub const fn with_max_concurrent_streams( self, max: usize, ) -> RequestHandlerBuilder

Sets the maximum number of concurrent streaming event queues.

Limits memory usage from concurrent streams. When the limit is reached, new streaming requests will fail.

Source

pub fn with_metrics( self, metrics: impl Metrics + 'static, ) -> RequestHandlerBuilder

Sets a metrics observer for handler activity.

Defaults to NoopMetrics which discards all events.

Source

pub fn build(self) -> Result<RequestHandler, ServerError>

Builds the RequestHandler.

§Errors

Returns ServerError::InvalidParams if the configuration is invalid:

  • Agent card with empty supported_interfaces
  • Zero executor timeout (would cause immediate timeouts)

Trait Implementations§

Source§

impl Debug for RequestHandlerBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. 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, 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