pub struct GrpcTaskStore { /* private fields */ }Expand description
Shared state backing both JSON-RPC and gRPC transports.
Stores task records, push-notification configuration, agent metadata, and
task-update fan-out channels for the gRPC service layer. The store is safe to
share across concurrent request handlers: task and push-configuration maps
use lock-free concurrent access through DashMap, while task updates are
distributed with a Tokio broadcast channel.
§Responsibilities
- Keep the authoritative in-process
local::Taskrecords by task ID. - Track per-task
local::TaskPushNotificationConfigentries used by push-notification subscribers. - Expose the local
local::AgentCardadvertised by this server. - Optionally publish task lifecycle events through
AgentBus. - Broadcast task status changes to active streaming subscribers.
§Invariants
- Keys in
tasksandpush_configsare task IDs. - Values sent through
update_txuse the same task ID namespace astasks. carddescribes the agent instance served by this store.
Implementations§
Source§impl GrpcTaskStore
impl GrpcTaskStore
Sourcepub fn new(card: AgentCard) -> Arc<Self> ⓘ
pub fn new(card: AgentCard) -> Arc<Self> ⓘ
Create a new task store with the given agent card.
Initializes an empty, shareable GrpcTaskStore for a single local
agent. The returned Arc is intended to be cloned into gRPC handlers,
JSON-RPC adapters, streaming tasks, and other transport glue that needs
access to the same in-process task state.
§Parameters
card- Agent metadata served by this store and returned to clients that request the local agent card.
§Returns
A reference-counted store with no tasks, no push-notification
configuration, no attached AgentBus, and a task-update broadcast
channel sized for 256 queued status updates per receiver.
§Side effects
Allocates the concurrent maps and creates a Tokio broadcast channel. It does not publish network services, spawn background tasks, or emit any task updates.
Sourcepub fn with_bus(card: AgentCard, bus: Arc<AgentBus>) -> Arc<Self> ⓘ
pub fn with_bus(card: AgentCard, bus: Arc<AgentBus>) -> Arc<Self> ⓘ
Create with an agent bus attached.
Constructs a new store using Self::new and attaches an AgentBus
before the store is shared. The bus allows gRPC task activity to be
mirrored into the broader agent-event system while preserving the same
task storage and update-stream behavior as Self::new.
§Parameters
card- Agent metadata served by this store.bus- Shared event bus used to publish or coordinate task activity outside the gRPC transport.
§Returns
A reference-counted store with the supplied bus installed.
§Panics
Panics only if the freshly created Arc is not uniquely owned before
installing the bus. Under normal control flow this cannot happen because
the Arc has just been returned by Self::new and has not yet been
cloned.
Sourcepub fn upsert_task(&self, task: Task)
pub fn upsert_task(&self, task: Task)
Insert or update a task.
Stores the provided task by its ID, replacing any existing task with the same ID. Before writing the task into the map, this method broadcasts the task’s current status so live subscribers can react to status changes.
§Parameters
task- Complete task record to insert or replace. Itsidfield is used as the storage key and as the task ID in the broadcast update.
§Side effects
Sends a best-effort status update on the broadcast channel and mutates the in-memory task map. If there are no active receivers, or if receivers have lagged, the broadcast result is ignored; the task is still stored.
Sourcepub fn get_task(&self, id: &str) -> Option<Task>
pub fn get_task(&self, id: &str) -> Option<Task>
Get a task by id.
Looks up a task in the in-memory store and returns an owned clone so the
caller can inspect or serialize it without holding a DashMap guard.
§Parameters
id- Task identifier to retrieve.
§Returns
Some(local::Task) when a task with the given ID exists, or None when
the store has no matching task.
§Side effects
This method does not mutate store state or emit task updates.
Sourcepub fn subscribe_updates(&self) -> Receiver<(String, TaskStatus)>
pub fn subscribe_updates(&self) -> Receiver<(String, TaskStatus)>
Subscribe to task update notifications.
Creates a new receiver for the live task-status broadcast stream. Each
message contains the task ID and the status observed by Self::upsert_task.
§Returns
A Tokio broadcast receiver for (task_id, status) tuples. Broadcast
receivers are live streams, not durable logs; slow receivers may observe
lag errors according to Tokio broadcast-channel semantics.
§Side effects
Registers a new receiver with the broadcast channel. It does not read, mutate, or replay existing tasks.
Sourcepub fn into_service(self: Arc<Self>) -> A2aServiceServer<A2aServiceImpl>
pub fn into_service(self: Arc<Self>) -> A2aServiceServer<A2aServiceImpl>
Build the tonic service layer from this store.
Wraps the shared task store in an A2aServiceImpl and returns the
generated tonic A2aServiceServer ready to be mounted into a gRPC
server.
§Returns
A tonic service server that handles A2A gRPC requests using this store as its backing state.
§Side effects
Consumes one Arc handle to the store and moves it into the service
implementation. This method does not start listening on a socket; the
caller is responsible for adding the returned service to a tonic server.
Auto Trait Implementations§
impl Freeze for GrpcTaskStore
impl !RefUnwindSafe for GrpcTaskStore
impl Send for GrpcTaskStore
impl Sync for GrpcTaskStore
impl Unpin for GrpcTaskStore
impl UnsafeUnpin for GrpcTaskStore
impl !UnwindSafe for GrpcTaskStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request