pub struct RequestHandler { /* private fields */ }Expand description
The core protocol logic handler.
Orchestrates task lifecycle, event streaming, push notifications, and interceptor chains for all A2A methods.
RequestHandler is not generic — it stores the executor as
Arc<dyn AgentExecutor>, enabling dynamic dispatch and simplifying
the downstream API (dispatchers, builder, etc.).
§Store ownership
Stores are held as Arc<dyn TaskStore> / Arc<dyn PushConfigStore>
rather than Box<dyn ...> so that they can be cheaply cloned into
background tasks (e.g. the streaming push-delivery processor).
Implementations§
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_cancel_task(
&self,
params: CancelTaskParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<Task>
pub async fn on_cancel_task( &self, params: CancelTaskParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<Task>
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_get_extended_agent_card(
&self,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<AgentCard>
pub async fn on_get_extended_agent_card( &self, headers: Option<&HashMap<String, String>>, ) -> ServerResult<AgentCard>
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_get_task(
&self,
params: TaskQueryParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<Task>
pub async fn on_get_task( &self, params: TaskQueryParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<Task>
Handles GetTask. Returns ServerError::TaskNotFound if missing.
§Errors
Returns ServerError::TaskNotFound if the task does not exist.
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_list_tasks(
&self,
params: ListTasksParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<TaskListResponse>
pub async fn on_list_tasks( &self, params: ListTasksParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<TaskListResponse>
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_resubscribe(
&self,
params: TaskIdParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<InMemoryQueueReader>
pub async fn on_resubscribe( &self, params: TaskIdParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<InMemoryQueueReader>
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_send_message(
&self,
params: MessageSendParams,
streaming: bool,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<SendMessageResult>
pub async fn on_send_message( &self, params: MessageSendParams, streaming: bool, headers: Option<&HashMap<String, String>>, ) -> ServerResult<SendMessageResult>
Handles SendMessage / SendStreamingMessage.
The optional headers map carries HTTP request headers for
interceptor access-control decisions (e.g. Authorization).
§Errors
Returns ServerError if task creation or execution fails.
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_set_push_config(
&self,
config: TaskPushNotificationConfig,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<TaskPushNotificationConfig>
pub async fn on_set_push_config( &self, config: TaskPushNotificationConfig, headers: Option<&HashMap<String, String>>, ) -> ServerResult<TaskPushNotificationConfig>
Handles CreateTaskPushNotificationConfig.
§Errors
Returns ServerError::PushNotSupported if no push sender is configured.
Sourcepub async fn on_get_push_config(
&self,
params: GetPushConfigParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<TaskPushNotificationConfig>
pub async fn on_get_push_config( &self, params: GetPushConfigParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<TaskPushNotificationConfig>
Handles GetTaskPushNotificationConfig.
§Errors
Returns ServerError::InvalidParams if the config is not found.
Sourcepub async fn on_list_push_configs(
&self,
task_id: &str,
tenant: Option<&str>,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<Vec<TaskPushNotificationConfig>>
pub async fn on_list_push_configs( &self, task_id: &str, tenant: Option<&str>, headers: Option<&HashMap<String, String>>, ) -> ServerResult<Vec<TaskPushNotificationConfig>>
Sourcepub async fn on_delete_push_config(
&self,
params: DeletePushConfigParams,
headers: Option<&HashMap<String, String>>,
) -> ServerResult<()>
pub async fn on_delete_push_config( &self, params: DeletePushConfigParams, headers: Option<&HashMap<String, String>>, ) -> ServerResult<()>
Handles DeleteTaskPushNotificationConfig.
§Errors
Returns a ServerError if the delete operation fails.
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Initiates graceful shutdown of the handler.
This method:
- Cancels all in-flight tasks by signalling their cancellation tokens.
- Destroys all event queues, causing readers to see EOF.
After calling shutdown(), new requests will still be accepted but
in-flight tasks will observe cancellation. The caller should stop
accepting new connections after calling this method.
Sourcepub async fn shutdown_with_timeout(&self, timeout: Duration)
pub async fn shutdown_with_timeout(&self, timeout: Duration)
Initiates graceful shutdown with a timeout.
Cancels all in-flight tasks and waits up to timeout for event queues
to drain before force-destroying them. This gives executors a chance
to finish writing final events before the queues are torn down.
Source§impl RequestHandler
impl RequestHandler
Sourcepub fn tenant_resolver(&self) -> Option<&dyn TenantResolver>
pub fn tenant_resolver(&self) -> Option<&dyn TenantResolver>
Returns the tenant resolver, if configured.
Use this in dispatchers or middleware to resolve the tenant identity
from a CallContext before processing a request.
Sourcepub const fn tenant_config(&self) -> Option<&PerTenantConfig>
pub const fn tenant_config(&self) -> Option<&PerTenantConfig>
Returns the per-tenant configuration, if configured.
Use this alongside tenant_resolver to look up
resource limits for the resolved tenant.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RequestHandler
impl !RefUnwindSafe for RequestHandler
impl Send for RequestHandler
impl Sync for RequestHandler
impl Unpin for RequestHandler
impl UnsafeUnpin for RequestHandler
impl !UnwindSafe for RequestHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request