pub struct RequestHandler { /* private fields */ }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
impl RequestHandler
Sourcepub fn new(
executor: Arc<V1Executor>,
task_store: Arc<dyn TaskStore>,
push_sender: Arc<dyn PushNotificationSender>,
agent_card: Arc<RwLock<CachedAgentCard>>,
) -> RequestHandler
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).
Sourcepub 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
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.
Sourcepub async fn message_send(&self, msg: Message) -> Result<Task, A2aError>
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.
Sourcepub async fn message_stream(
&self,
msg: Message,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>
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.
Sourcepub async fn tasks_get(
&self,
task_id: &str,
history_len: Option<u32>,
) -> Result<Task, A2aError>
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.
Sourcepub async fn tasks_cancel(&self, task_id: &str) -> Result<Task, A2aError>
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.
Sourcepub async fn tasks_list(
&self,
params: ListTasksParams,
) -> Result<Vec<Task>, A2aError>
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.
Sourcepub async fn tasks_subscribe(
&self,
task_id: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>
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.
Sourcepub async fn push_config_create(
&self,
task_id: &str,
config: TaskPushNotificationConfig,
) -> Result<TaskPushNotificationConfig, A2aError>
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.
Sourcepub async fn push_config_get(
&self,
task_id: &str,
config_id: &str,
) -> Result<TaskPushNotificationConfig, A2aError>
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.
Sourcepub async fn push_config_list(
&self,
task_id: &str,
) -> Result<Vec<TaskPushNotificationConfig>, A2aError>
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.
Sourcepub async fn push_config_delete(
&self,
task_id: &str,
config_id: &str,
) -> Result<(), A2aError>
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.
Sourcepub async fn agent_card_extended(&self) -> Result<AgentCard, A2aError>
pub async fn agent_card_extended(&self) -> Result<AgentCard, A2aError>
Returns the extended agent card.
§Errors
Returns A2aError::ExtendedAgentCardNotConfigured if no card is set.
Sourcepub fn executor(&self) -> &Arc<V1Executor> ⓘ
pub fn executor(&self) -> &Arc<V1Executor> ⓘ
Returns a reference to the underlying executor.
Sourcepub fn task_store(&self) -> &Arc<dyn TaskStore> ⓘ
pub fn task_store(&self) -> &Arc<dyn TaskStore> ⓘ
Returns a reference to the underlying task store.