pub struct PostgresPushOutbox { /* private fields */ }Expand description
A PushOutbox in a PostgreSQL database; see the module documentation.
Implementations§
Source§impl PostgresPushOutbox
impl PostgresPushOutbox
Sourcepub async fn new(url: &str) -> Result<PostgresPushOutbox, Error>
pub async fn new(url: &str) -> Result<PostgresPushOutbox, Error>
Opens a pool of DEFAULT_POOL_SIZE
connections to url, with the task stores’ options
(store::pg_retry), and creates the table under the crate’s schema
lock.
§Errors
The database cannot be reached, or the table created.
Sourcepub async fn from_pool(
pool: Pool<Postgres>,
) -> Result<PostgresPushOutbox, Error>
pub async fn from_pool( pool: Pool<Postgres>, ) -> Result<PostgresPushOutbox, Error>
Sourcepub fn with_cipher(
self,
cipher: Arc<dyn PushConfigCipher>,
) -> PostgresPushOutbox
pub fn with_cipher( self, cipher: Arc<dyn PushConfigCipher>, ) -> PostgresPushOutbox
Seals every event body with cipher; see
SqlitePushOutbox::with_cipher.
Sourcepub fn with_metrics(self, metrics: Arc<dyn Metrics>) -> PostgresPushOutbox
pub fn with_metrics(self, metrics: Arc<dyn Metrics>) -> PostgresPushOutbox
Reports a statement run again after a lost connection to metrics
(Metrics::on_store_retry).
Trait Implementations§
Source§impl Clone for PostgresPushOutbox
impl Clone for PostgresPushOutbox
Source§fn clone(&self) -> PostgresPushOutbox
fn clone(&self) -> PostgresPushOutbox
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PostgresPushOutbox
impl Debug for PostgresPushOutbox
Source§impl PushOutbox for PostgresPushOutbox
impl PushOutbox for PostgresPushOutbox
Source§fn record(
&self,
deliveries: Vec<NewDelivery>,
per_webhook: usize,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>
fn record( &self, deliveries: Vec<NewDelivery>, per_webhook: usize, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>
Records
deliveries, in order. A delivery whose delivery_id is already
in the outbox is left as it is (recording the same delivery twice keeps
one row, so a caller can record again what it is unsure was recorded);
one that was delivered and removed is recorded again, and delivered again
under the same id, which a receiver sees as a retry. At most per_webhook rows wait for one
webhook of one task: past that, recording one drops the oldest of them
that is not claimed and does not end a turn, or, when there is none,
the new one unless it ends a turn (kept past the bound). Returns how
many were dropped.Source§fn supports_reservations(&self) -> bool
fn supports_reservations(&self) -> bool
Whether this outbox keeps reservations (
reserve).
One that does not (the default) is recorded in only after an event is
stored, and a crash between the two loses that event’s deliveries.Source§fn reserve<'a>(
&'a self,
reservation: &'a str,
log_seq: u64,
deliveries: Vec<NewDelivery>,
per_webhook: usize,
hold: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
fn reserve<'a>( &'a self, reservation: &'a str, log_seq: u64, deliveries: Vec<NewDelivery>, per_webhook: usize, hold: Duration, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
Phase one of recording an event’s deliveries before the event is
stored (audit H14):
deliveries, all of one event at position
log_seq of its task’s log, are written unarmed. Read moreSource§fn arm<'a>(
&'a self,
reservation: &'a str,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
fn arm<'a>( &'a self, reservation: &'a str, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
Phase two, the event was stored: the rows of
reservation become
claimable. Returns how many rows the reservation has, armed by this
call or already; 0 means there is nothing of it left (it was
released, or settled by another replica as not stored, or already
delivered), and the caller records the deliveries afresh. Read moreSource§fn extend_hold<'a>(
&'a self,
reservation: &'a str,
hold: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
fn extend_hold<'a>( &'a self, reservation: &'a str, hold: Duration, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
Extends to
hold from now the hold of reservation, if it is still
held (not armed, not released): the heartbeat of a reserver that is
still alive and whose event is still being written (adversarial review
R3). Returns how many rows it extended; 0 means nothing of it is left
to extend (it was settled by a replica whose worker saw the hold run
out, or released). Read moreSource§fn release<'a>(
&'a self,
reservation: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn release<'a>( &'a self, reservation: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
The event was not stored: removes the rows of
reservation that are
not armed. Armed rows, and a reservation that is gone, are left
alone. Read moreSource§fn held(
&self,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Held>, A2aError>> + Send + '_>>
fn held( &self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Held>, A2aError>> + Send + '_>>
Up to
limit reservations that are not armed and whose hold has run
out, oldest first, one entry each however many webhooks it has rows
for. Read moreSource§fn held_for_task<'a>(
&'a self,
tenant: &'a str,
caller: Option<&'a str>,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Held>, A2aError>> + Send + 'a>>
fn held_for_task<'a>( &'a self, tenant: &'a str, caller: Option<&'a str>, task_id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Held>, A2aError>> + Send + 'a>>
Every reservation of one task that is not armed, whether or not its hold
has run out: for a caller that knows the reserver can write no more, such
as the reaper once it holds the task’s turn claim (a store refuses a
writer whose claim was taken over, so what the task store holds is final). Read more
Source§fn supports_renewal(&self) -> bool
fn supports_renewal(&self) -> bool
Whether this outbox renews leases (
renew). With renewal a
worker claims for a short lease and renews it while it works, so the
rows of a worker that died are free after one short lease, not after the
longest a delivery can take; without it (the default) the worker takes
the long lease.Source§fn renew<'a>(
&'a self,
owner: &'a str,
lease: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
fn renew<'a>( &'a self, owner: &'a str, lease: Duration, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>>
Extends to
lease from now every unexpired lease owner holds: the
worker’s heartbeat. Returns how many rows it renewed. Read moreSource§fn claim<'a>(
&'a self,
owner: &'a str,
max: usize,
lease: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<ClaimedDelivery>, A2aError>> + Send + 'a>>
fn claim<'a>( &'a self, owner: &'a str, max: usize, lease: Duration, ) -> Pin<Box<dyn Future<Output = Result<Vec<ClaimedDelivery>, A2aError>> + Send + 'a>>
Claims up to
max rows that are due, not under another owner’s lease,
and have no earlier unfinished row of the same tenant, caller, task and
config, for owner, for lease. In record order.Source§fn complete(
&self,
seq: i64,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + '_>>
fn complete( &self, seq: i64, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + '_>>
Removes row
seq: delivered, refused for good, expired, or its config
is gone. Harmless when it is already gone.Source§fn retry_after<'a>(
&'a self,
seq: i64,
owner: &'a str,
after: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn retry_after<'a>( &'a self, seq: i64, owner: &'a str, after: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Makes row
seq due again after from now, one attempt more, and
releases it, when owner still holds its lease; otherwise does
nothing (another owner has it, and will finish it).Source§fn pending(
&self,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>
fn pending( &self, ) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>
How many rows wait, claimed or not, reserved or not: for a gauge.
Source§fn is_process_local(&self) -> bool
fn is_process_local(&self) -> bool
Whether this outbox keeps its rows in this process alone, so that a
delivery owed when the process stops is never made. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresPushOutbox
impl !UnwindSafe for PostgresPushOutbox
impl Forget for PostgresPushOutbox
impl Freeze for PostgresPushOutbox
impl Move for PostgresPushOutbox
impl Send for PostgresPushOutbox
impl Sync for PostgresPushOutbox
impl Unpin for PostgresPushOutbox
impl UnsafeUnpin for PostgresPushOutbox
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
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>,
Applies the layer to a service and wraps it in [
Layered].