Skip to main content

RequestHandler

Struct RequestHandler 

Source
pub struct RequestHandler { /* private fields */ }
Available on crate features server and a2a-v1 only.
Expand description

Shared dispatch layer for A2A v1.0.0 operations.

Maps operation names to executor/store calls. Used by both the JSON-RPC handler and the REST handler.

When constructed with a adk_runner::RunnerConfig via RequestHandler::with_runner, message_send and message_stream invoke the agent through the ADK Runner for real LLM generation. Without a runner config, they perform state transitions only (useful for protocol-level testing).

Implementations§

Source§

impl RequestHandler

Source

pub fn new( executor: Arc<V1Executor>, task_store: Arc<dyn TaskStore>, push_sender: Arc<dyn PushNotificationSender>, agent_card: Arc<RwLock<CachedAgentCard>>, ) -> RequestHandler

Creates a new request handler without a runner (stub mode).

Source

pub fn with_runner( executor: Arc<V1Executor>, task_store: Arc<dyn TaskStore>, push_sender: Arc<dyn PushNotificationSender>, agent_card: Arc<RwLock<CachedAgentCard>>, runner_config: Arc<RunnerConfig>, ) -> RequestHandler

Creates a new request handler with a runner for real LLM invocation.

Source

pub async fn message_send(&self, msg: Message) -> Result<Task, A2aError>

Sends a message, creating a task and processing it through the executor.

When a runner config is present, invokes the agent through the ADK Runner for real LLM generation. The LLM response is recorded as an artifact on the task. Without a runner, performs state transitions only.

§Errors

Returns an error if task creation, state transitions, or store operations fail.

Source

pub async fn message_stream( &self, msg: Message, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>

Sends a streaming message, returning a stream of SSE events.

Creates a task, yields status update events as the task progresses. This is a placeholder — actual Runner streaming integration comes later.

§Errors

Returns an error if task creation fails.

Source

pub async fn tasks_get( &self, task_id: &str, history_len: Option<u32>, ) -> Result<Task, A2aError>

Retrieves a task by ID from the task store.

Optionally limits the number of history messages returned.

§Errors

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

Source

pub async fn tasks_cancel(&self, task_id: &str) -> Result<Task, A2aError>

Cancels a task by transitioning it to CANCELED state.

Validates that the task is not already in a terminal state before canceling.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or A2aError::TaskNotCancelable if the task is in a terminal state.

Source

pub async fn tasks_list( &self, params: ListTasksParams, ) -> Result<Vec<Task>, A2aError>

Lists tasks matching the given parameters.

Supports filtering by context_id, state, and pagination via page_size.

Source

pub async fn tasks_subscribe( &self, task_id: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>

Subscribes to task updates via SSE.

Placeholder — returns a stream that yields the current task status. Full SSE subscription will be implemented in a later task.

§Errors

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

Source

pub async fn push_config_create( &self, task_id: &str, config: TaskPushNotificationConfig, ) -> Result<TaskPushNotificationConfig, A2aError>

Creates a push notification configuration for a task.

Assigns a server-generated config ID and stores the config on the task.

§Errors

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

Source

pub async fn push_config_get( &self, task_id: &str, config_id: &str, ) -> Result<TaskPushNotificationConfig, A2aError>

Retrieves a push notification configuration by task ID and config ID.

§Errors

Returns A2aError::TaskNotFound if the task or config does not exist.

Source

pub async fn push_config_list( &self, task_id: &str, ) -> Result<Vec<TaskPushNotificationConfig>, A2aError>

Lists all push notification configurations for a task.

§Errors

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

Source

pub async fn push_config_delete( &self, task_id: &str, config_id: &str, ) -> Result<(), A2aError>

Deletes a push notification configuration.

§Errors

Returns A2aError::TaskNotFound if the task or config does not exist.

Source

pub async fn agent_card_extended(&self) -> Result<AgentCard, A2aError>

Returns the extended agent card.

§Errors

Returns A2aError::ExtendedAgentCardNotConfigured if no card is set.

Source

pub fn executor(&self) -> &Arc<V1Executor>

Returns a reference to the underlying executor.

Source

pub fn task_store(&self) -> &Arc<dyn TaskStore>

Returns a reference to the underlying task store.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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