pub struct PostgresHaltStore { /* private fields */ }Expand description
Halts in a PostgreSQL table, a2a_halts, created if absent.
Each write and removal notifies a2a_halts in its own transaction, and
a cancel notifies a2a_cancels; one listener per store (its clones
share it) forwards both to the handlers holding it. The listener holds
one connection of its own and ends when the last clone is dropped.
§Behind a connection pooler
LISTEN belongs to a session. A pooler in transaction mode (PgBouncer‘s
pool_mode = transaction, the usual setting) runs it on whichever
server connection it lends, then lends that connection to someone else
still listening, and the next notification lands in the middle of that
client’s statement: sqlx fails it with unexpected message: NotificationResponse. Seen live through PgBouncer 1.26.1 (2026-10-30):
the halt itself failed to be written. So behind such a pooler, build the
store with from_pool_listening_at, the
listener on a direct connection to PostgreSQL, or with
from_pool_without_listener, the
handlers then learning of other replicas’ halts and cancels at their
next poll.
Implementations§
Source§impl PostgresHaltStore
impl PostgresHaltStore
Sourcepub async fn from_pool(
pool: Pool<Postgres>,
) -> Result<PostgresHaltStore, A2aError>
pub async fn from_pool( pool: Pool<Postgres>, ) -> Result<PostgresHaltStore, A2aError>
Uses pool, usually the task store’s, and creates the table under
the crate’s schema lock, so replicas starting together do not race.
§Errors
A2aError::internal if the table cannot be created.
Sourcepub async fn from_pool_listening_at(
pool: Pool<Postgres>,
listen_url: impl Into<String>,
) -> Result<PostgresHaltStore, A2aError>
pub async fn from_pool_listening_at( pool: Pool<Postgres>, listen_url: impl Into<String>, ) -> Result<PostgresHaltStore, A2aError>
Uses pool for every statement and listens on a connection of its
own to listen_url: for a pool that goes through a pooler in
transaction mode, listen_url names PostgreSQL directly (see
Behind a connection pooler above).
§Errors
A2aError::internal if the table cannot be created. A listener
that cannot connect retries every second and is not an error here.
Sourcepub async fn from_pool_without_listener(
pool: Pool<Postgres>,
) -> Result<PostgresHaltStore, A2aError>
pub async fn from_pool_without_listener( pool: Pool<Postgres>, ) -> Result<PostgresHaltStore, A2aError>
Uses pool and listens to nothing: signals
is None, and a handler learns of other replicas’ halts and cancels
at its next poll (with_halt_poll_interval).
For a pooler in transaction mode with no direct route to PostgreSQL.
§Errors
A2aError::internal if the table cannot be created.
Trait Implementations§
Source§impl Clone for PostgresHaltStore
impl Clone for PostgresHaltStore
Source§fn clone(&self) -> PostgresHaltStore
fn clone(&self) -> PostgresHaltStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresHaltStore
impl Debug for PostgresHaltStore
Source§impl HaltStore for PostgresHaltStore
impl HaltStore for PostgresHaltStore
Source§fn load(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredHalt>, A2aError>> + Send + '_>>
fn load( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredHalt>, A2aError>> + Send + '_>>
Source§fn put<'a>(
&'a self,
halt: &'a StoredHalt,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn put<'a>( &'a self, halt: &'a StoredHalt, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
halt, replacing a halt of the same scope. Read moreSource§fn remove<'a>(
&'a self,
scope: &'a HaltScope,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn remove<'a>( &'a self, scope: &'a HaltScope, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
scope; whether there was one. Read moreSource§fn signals(&self) -> Option<Receiver<HaltSignal>>
fn signals(&self) -> Option<Receiver<HaltSignal>>
None (the
default) for a store that cannot push; the handler then polls only.Source§fn publish_cancel<'a>(
&'a self,
tenant: &'a str,
task: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn publish_cancel<'a>( &'a self, tenant: &'a str, task: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
task in tenant was
cancelled. The default does nothing: without a push, the executor
running the task learns of it at its next refused write. Read moreSource§fn is_process_local(&self) -> bool
fn is_process_local(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresHaltStore
impl !UnwindSafe for PostgresHaltStore
impl Forget for PostgresHaltStore
impl Freeze for PostgresHaltStore
impl Move for PostgresHaltStore
impl Send for PostgresHaltStore
impl Sync for PostgresHaltStore
impl Unpin for PostgresHaltStore
impl UnsafeUnpin for PostgresHaltStore
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].