pub struct RequestHandlerBuilder { /* private fields */ }Expand description
Fluent builder for RequestHandler.
§Required
executor: AnyAgentExecutorimplementation (passed as a concrete type; the builder erases it toArc<dyn AgentExecutor>duringbuild).
§Optional (with defaults)
task_store: defaults toInMemoryTaskStore.push_config_store: defaults toInMemoryPushConfigStore.push_sender: defaults toNone.interceptors: defaults to an empty chain.agent_card: defaults toNone.
Implementations§
Source§impl RequestHandlerBuilder
impl RequestHandlerBuilder
Sourcepub fn new(executor: impl AgentExecutor) -> Self
pub fn new(executor: impl AgentExecutor) -> Self
Creates a new builder with the given executor.
The executor is type-erased to Arc<dyn AgentExecutor>.
Sourcepub fn with_task_store(self, store: impl TaskStore + 'static) -> Self
pub fn with_task_store(self, store: impl TaskStore + 'static) -> Self
Sets a custom task store.
Sourcepub const fn with_task_store_config(self, config: TaskStoreConfig) -> Self
pub const fn with_task_store_config(self, config: TaskStoreConfig) -> Self
Configures the default InMemoryTaskStore with custom TTL and capacity settings.
This is ignored if a custom task store is set via with_task_store.
Sourcepub fn with_push_config_store(
self,
store: impl PushConfigStore + 'static,
) -> Self
pub fn with_push_config_store( self, store: impl PushConfigStore + 'static, ) -> Self
Sets a custom push configuration store.
Sourcepub fn with_push_sender(self, sender: impl PushSender + 'static) -> Self
pub fn with_push_sender(self, sender: impl PushSender + 'static) -> Self
Sets a push notification sender.
Sourcepub fn with_interceptor(
self,
interceptor: impl ServerInterceptor + 'static,
) -> Self
pub fn with_interceptor( self, interceptor: impl ServerInterceptor + 'static, ) -> Self
Adds a server interceptor to the chain.
Sourcepub const fn with_executor_timeout(self, timeout: Duration) -> Self
pub const fn with_executor_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn with_agent_card(self, card: AgentCard) -> Self
pub fn with_agent_card(self, card: AgentCard) -> Self
Sets the agent card for discovery responses.
Sourcepub const fn with_event_queue_capacity(self, capacity: usize) -> Self
pub const fn with_event_queue_capacity(self, capacity: usize) -> Self
Sets the event queue channel capacity for streaming.
Defaults to 64 items. Higher values allow more events to be buffered before backpressure is applied.
Sourcepub const fn with_max_event_size(self, max_event_size: usize) -> Self
pub const fn with_max_event_size(self, max_event_size: usize) -> Self
Sets the maximum serialized event size in bytes.
Events exceeding this size are rejected to prevent OOM conditions. Defaults to 16 MiB.
Sourcepub const fn with_max_concurrent_streams(self, max: usize) -> Self
pub const fn with_max_concurrent_streams(self, max: usize) -> Self
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.
Sourcepub fn with_metrics(self, metrics: impl Metrics + 'static) -> Self
pub fn with_metrics(self, metrics: impl Metrics + 'static) -> Self
Sets a metrics observer for handler activity.
Defaults to NoopMetrics which discards all events.
Sourcepub fn build(self) -> ServerResult<RequestHandler>
pub fn build(self) -> ServerResult<RequestHandler>
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)