Skip to main content

RequestHandler

Struct RequestHandler 

Source
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

Source

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.

Source

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.

Source

pub async fn on_list_tasks( &self, params: ListTasksParams, ) -> ServerResult<TaskListResponse>

Handles ListTasks.

§Errors

Returns a ServerError if the store query fails.

Source

pub async fn on_cancel_task( &self, params: CancelTaskParams, ) -> ServerResult<Task>

Handles CancelTask.

§Errors

Returns ServerError::TaskNotFound or ServerError::TaskNotCancelable.

Source

pub async fn on_resubscribe( &self, params: TaskIdParams, ) -> ServerResult<InMemoryQueueReader>

Handles SubscribeToTask.

§Errors

Returns ServerError::TaskNotFound if the task does not exist.

Source

pub async fn on_set_push_config( &self, config: TaskPushNotificationConfig, ) -> ServerResult<TaskPushNotificationConfig>

Handles CreateTaskPushNotificationConfig.

§Errors

Returns ServerError::PushNotSupported if no push sender is configured.

Source

pub async fn on_get_push_config( &self, params: GetPushConfigParams, ) -> ServerResult<TaskPushNotificationConfig>

Handles GetTaskPushNotificationConfig.

§Errors

Returns ServerError::InvalidParams if the config is not found.

Source

pub async fn on_list_push_configs( &self, task_id: &str, ) -> ServerResult<Vec<TaskPushNotificationConfig>>

Handles ListTaskPushNotificationConfigs.

§Errors

Returns a ServerError if the store query fails.

Source

pub async fn on_delete_push_config( &self, params: DeletePushConfigParams, ) -> ServerResult<()>

Handles DeleteTaskPushNotificationConfig.

§Errors

Returns a ServerError if the delete operation fails.

Source

pub async fn on_get_extended_agent_card(&self) -> ServerResult<AgentCard>

Handles GetExtendedAgentCard.

§Errors

Returns ServerError::Internal if no agent card is configured.

Source§

impl RequestHandler

Source

pub async fn shutdown(&self)

Initiates graceful shutdown of the handler.

This method:

  1. Cancels all in-flight tasks by signalling their cancellation tokens.
  2. 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.

Source

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.

Trait Implementations§

Source§

impl Debug for RequestHandler

Source§

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

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