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.).
Implementations§
Source§impl RequestHandler
impl RequestHandler
Sourcepub async fn on_send_message(
&self,
params: MessageSendParams,
streaming: bool,
) -> ServerResult<SendMessageResult>
pub async fn on_send_message( &self, params: MessageSendParams, streaming: bool, ) -> ServerResult<SendMessageResult>
Handles SendMessage / SendStreamingMessage.
§Errors
Returns ServerError if task creation or execution fails.
Sourcepub async fn on_get_task(&self, params: TaskQueryParams) -> ServerResult<Task>
pub async fn on_get_task(&self, params: TaskQueryParams) -> ServerResult<Task>
Handles GetTask. Returns ServerError::TaskNotFound if missing.
§Errors
Returns ServerError::TaskNotFound if the task does not exist.
Sourcepub async fn on_list_tasks(
&self,
params: ListTasksParams,
) -> ServerResult<TaskListResponse>
pub async fn on_list_tasks( &self, params: ListTasksParams, ) -> ServerResult<TaskListResponse>
Sourcepub async fn on_cancel_task(
&self,
params: CancelTaskParams,
) -> ServerResult<Task>
pub async fn on_cancel_task( &self, params: CancelTaskParams, ) -> ServerResult<Task>
Sourcepub async fn on_resubscribe(
&self,
params: TaskIdParams,
) -> ServerResult<InMemoryQueueReader>
pub async fn on_resubscribe( &self, params: TaskIdParams, ) -> ServerResult<InMemoryQueueReader>
Sourcepub async fn on_set_push_config(
&self,
config: TaskPushNotificationConfig,
) -> ServerResult<TaskPushNotificationConfig>
pub async fn on_set_push_config( &self, config: TaskPushNotificationConfig, ) -> ServerResult<TaskPushNotificationConfig>
Handles CreateTaskPushNotificationConfig.
§Errors
Returns ServerError::PushNotSupported if no push sender is configured.
Sourcepub async fn on_get_push_config(
&self,
params: GetPushConfigParams,
) -> ServerResult<TaskPushNotificationConfig>
pub async fn on_get_push_config( &self, params: GetPushConfigParams, ) -> 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,
) -> ServerResult<Vec<TaskPushNotificationConfig>>
pub async fn on_list_push_configs( &self, task_id: &str, ) -> ServerResult<Vec<TaskPushNotificationConfig>>
Sourcepub async fn on_delete_push_config(
&self,
params: DeletePushConfigParams,
) -> ServerResult<()>
pub async fn on_delete_push_config( &self, params: DeletePushConfigParams, ) -> ServerResult<()>
Handles DeleteTaskPushNotificationConfig.
§Errors
Returns a ServerError if the delete operation fails.
Sourcepub async fn on_get_extended_agent_card(&self) -> ServerResult<AgentCard>
pub async fn on_get_extended_agent_card(&self) -> ServerResult<AgentCard>
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.