pub struct V1Executor { /* private fields */ }server and a2a-v1 only.Expand description
V1 executor that wraps task lifecycle with TaskStore persistence
and state machine validation.
§Example
use std::sync::Arc;
use adk_server::a2a::v1::executor::V1Executor;
use adk_server::a2a::v1::task_store::InMemoryTaskStore;
let store = Arc::new(InMemoryTaskStore::new());
let executor = V1Executor::new(store);
let entry = executor.create_task("task-1", "ctx-1").await?;
let event = executor.transition_state("task-1", "ctx-1", TaskState::Working, None).await?;Implementations§
Source§impl V1Executor
impl V1Executor
Sourcepub fn new(task_store: Arc<dyn TaskStore>) -> V1Executor
pub fn new(task_store: Arc<dyn TaskStore>) -> V1Executor
Creates a new V1 executor backed by the given task store.
Sourcepub async fn create_task(
&self,
task_id: &str,
context_id: &str,
) -> Result<TaskStoreEntry, A2aError>
pub async fn create_task( &self, task_id: &str, context_id: &str, ) -> Result<TaskStoreEntry, A2aError>
Creates a new task in the store with TaskState::Submitted.
§Errors
Returns an error if the task store fails to persist the entry.
Sourcepub async fn transition_state(
&self,
task_id: &str,
context_id: &str,
new_state: TaskState,
message: Option<String>,
) -> Result<TaskStatusUpdateEvent, A2aError>
pub async fn transition_state( &self, task_id: &str, context_id: &str, new_state: TaskState, message: Option<String>, ) -> Result<TaskStatusUpdateEvent, A2aError>
Transitions a task to a new state, validating via the state machine.
Retrieves the current task from the store, validates the transition
with can_transition_to, persists the new status, and returns
a TaskStatusUpdateEvent with contextId, timestamp, and metadata.
§Errors
Returns A2aError::TaskNotFound if the task does not exist, or
A2aError::InvalidStateTransition if the transition is not allowed.
Sourcepub async fn record_artifact(
&self,
task_id: &str,
context_id: &str,
artifact: Artifact,
) -> Result<TaskArtifactUpdateEvent, A2aError>
pub async fn record_artifact( &self, task_id: &str, context_id: &str, artifact: Artifact, ) -> Result<TaskArtifactUpdateEvent, A2aError>
Records an artifact for a task.
Persists the artifact to the task store and returns a
TaskArtifactUpdateEvent with contextId and metadata.
§Errors
Returns A2aError::TaskNotFound if the task does not exist.
Sourcepub async fn fail_task(
&self,
task_id: &str,
context_id: &str,
error_message: &str,
) -> Result<TaskStatusUpdateEvent, A2aError>
pub async fn fail_task( &self, task_id: &str, context_id: &str, error_message: &str, ) -> Result<TaskStatusUpdateEvent, A2aError>
Marks a task as failed with error details.
Validates the transition to TaskState::Failed via the state machine,
persists the failed status with an error message, and returns the
corresponding TaskStatusUpdateEvent.
§Errors
Returns A2aError::TaskNotFound if the task does not exist, or
A2aError::InvalidStateTransition if the transition is not allowed.
Sourcepub fn task_store(&self) -> &Arc<dyn TaskStore> ⓘ
pub fn task_store(&self) -> &Arc<dyn TaskStore> ⓘ
Returns a reference to the underlying task store.