pub trait PushOutbox:
Send
+ Sync
+ 'static {
Show 15 methods
// Required methods
fn record(
&self,
deliveries: Vec<NewDelivery>,
per_webhook: usize,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>;
fn claim<'a>(
&'a self,
owner: &'a str,
max: usize,
lease: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<ClaimedDelivery>, A2aError>> + Send + 'a>>;
fn complete(
&self,
seq: i64,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + '_>>;
fn retry_after<'a>(
&'a self,
seq: i64,
owner: &'a str,
after: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;
fn pending(
&self,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + '_>>;
// Provided methods
fn is_process_local(&self) -> bool { ... }
fn supports_renewal(&self) -> bool { ... }
fn renew<'a>(
&'a self,
owner: &'a str,
lease: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>> { ... }
fn supports_reservations(&self) -> bool { ... }
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 arm<'a>(
&'a self,
reservation: &'a str,
) -> Pin<Box<dyn Future<Output = Result<usize, A2aError>> + Send + 'a>> { ... }
fn release<'a>(
&'a self,
reservation: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>> { ... }
fn extend_hold<'a>(
&'a self,
reservation: &'a str,
hold: Duration,
) -> Pin<Box<dyn Future<Output = Result<usize, 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>> { ... }
fn held(
&self,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Held>, A2aError>> + Send + '_>> { ... }
}Expand description
Where webhook deliveries wait until they are delivered; see the module documentation.
A row is claimed by one owner at a time, under a lease: until the lease runs out no other claim returns it, and once it has, any may. An owner that stops mid-delivery leaves its rows to the next claim after their leases.
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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).
Provided Methods§
Sourcefn 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.
The default is false, as for the store traits: an outbox this crate
cannot see into is taken to be durable. InMemoryPushOutbox answers
true, and so does a SqlitePushOutbox over sqlite::memory:.
Profile::DurableProduction
refuses an outbox that answers true.
Sourcefn 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.
Sourcefn 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.
§Errors
The outbox cannot be written, or does not renew.
Sourcefn 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.
Sourcefn 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.
An unarmed row is not claimed, but it holds its webhook’s place: no
later row of the same webhook is claimed past it, so the order of a
webhook’s deliveries is the order of the events whether or not they
have been stored yet. It is never dropped to make room for another
row. The caller then either arms the reservation once
the event is stored, or releases it if it was not.
If the caller stops between the two, the rows are left with a hold
that runs out; held then lists the reservation, and
whoever settles it decides from the task store whether the event was
stored. Like record, returns how many rows were
dropped for the per_webhook bound.
§Errors
The outbox cannot be written, or keeps no reservations.
Sourcefn 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.
§Errors
The outbox cannot be written, or keeps no reservations.
Sourcefn 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.
§Errors
The outbox cannot be written, or keeps no reservations.
Sourcefn 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).
Without a heartbeat a hold is a wall-clock guess that no write outlasts; with one, a worker settles only a reservation whose reserver has stopped renewing it, which a live writer, however slow its store, does not.
§Errors
The outbox cannot be written, keeps no reservations, or does not extend a hold (the default): the reserver then relies on the hold it set.
Sourcefn 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).
§Errors
The outbox cannot be read, or keeps no reservations.
Sourcefn 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.
§Errors
The outbox cannot be read, or keeps no reservations.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".