Skip to main content

GrpcTaskStore

Struct GrpcTaskStore 

Source
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::Task records by task ID.
  • Track per-task local::TaskPushNotificationConfig entries used by push-notification subscribers.
  • Expose the local local::AgentCard advertised by this server.
  • Optionally publish task lifecycle events through AgentBus.
  • Broadcast task status changes to active streaming subscribers.

§Invariants

  • Keys in tasks and push_configs are task IDs.
  • Values sent through update_tx use the same task ID namespace as tasks.
  • card describes the agent instance served by this store.

Implementations§

Source§

impl GrpcTaskStore

Source

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.

Source

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.

Source

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. Its id field 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.

Source

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.

Source

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.

Source

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§

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<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ServiceExt for T

Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,