Skip to main content

TaskEventSink

Struct TaskEventSink 

Source
pub struct TaskEventSink { /* private fields */ }
Expand description

Publish wrapper for cross-replica task event fanout. Replaces the previous tokio::sync::broadcast::Sender<TaskEvent> returned by A2aDispatcher::event_sink.

The sink shares an Arc<Semaphore> with its parent A2aDispatcher so Self::send can bound the number of concurrent in-flight publishes. See Self::send for the saturation-drop semantics.

Implementations§

Source§

impl TaskEventSink

Source

pub fn new(pubsub: Arc<dyn Pubsub>) -> Self

Wrap an Arc<dyn Pubsub> for publishing per-task events with a fresh, single-replica default semaphore (DEFAULT_PUBLISH_PERMITS permits). Multi-replica deployments or any wiring that wants to share the dispatcher’s bound should go through A2aDispatcher::event_sink instead, which threads the dispatcher’s semaphore through.

Source

pub fn with_permits(pubsub: Arc<dyn Pubsub>, permits: Arc<Semaphore>) -> Self

Wrap an Arc<dyn Pubsub> with an explicit publish-concurrency semaphore. Used by A2aDispatcher::event_sink to share the dispatcher’s bound across every sink it hands out. The semaphore’s available_permits() caps the number of concurrent publishes Self::send will execute; excess sends drop with Ok(()) and a warn log.

Source

pub async fn send(&self, event: TaskEvent) -> Result<(), A2aError>

Publish event on the per-task bus subject klieo.a2a.task.{event.task_id}.

task_id is validated against klieo_core::validate_subject_token before subject construction; metacharacters (., *, >, whitespace, non-ASCII) yield A2aError::Bus(BusError::Invalid(_)), preventing a caller-controlled task id from collapsing or wildcarding the subject namespace (CWE-74).

§Backpressure

Acquires a permit from the shared semaphore via Semaphore::try_acquire_owned BEFORE awaiting the publish. When the semaphore is saturated the event is dropped, a warn is logged at target a2a.fanout with available_permits = 0, and the method returns Ok(()) — task event fanout is best-effort (matches the cluster-0.18 contract in crate::task_store::A2aTaskStore which already tolerates publish failures), and surfacing the saturation as an error would propagate into store writes that succeeded.

Publish failures surface as A2aError::Bus(_); server-side encode failures (effectively impossible for a server-built TaskEvent) surface as A2aError::Internal { source } so the wire envelope is SERVER_ERROR (-32000) rather than PARSE_ERROR (-32700). Both preserve e.source() for downstream tracing.

Trait Implementations§

Source§

impl Clone for TaskEventSink

Source§

fn clone(&self) -> TaskEventSink

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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