fix: defer blocked deliveries, claim owner token
This commit is contained in:
@@ -148,6 +148,11 @@ pub enum DomainEvent {
|
||||
pub trait AckHandle: Send + Sync {
|
||||
async fn ack(&self) -> Result<(), DomainError>;
|
||||
async fn nack(&self) -> Result<(), DomainError>;
|
||||
/// Redeliver after `delay` without counting a failed attempt: for a
|
||||
/// delivery that was not tried (it is blocked behind a live claim), so it
|
||||
/// must not burn the retry budget that `nack` spends. A broker may still
|
||||
/// count the redelivery itself: JetStream does, toward `max_deliver`.
|
||||
async fn defer(&self, delay: std::time::Duration) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
/// Stable identity of one queued event; the key for de-duplicating deliveries.
|
||||
@@ -194,6 +199,10 @@ impl EventEnvelope {
|
||||
self.ack.ack().await
|
||||
}
|
||||
|
||||
pub async fn defer(self, delay: std::time::Duration) -> Result<(), DomainError> {
|
||||
self.ack.defer(delay).await
|
||||
}
|
||||
|
||||
pub async fn nack(self) -> Result<(), DomainError> {
|
||||
self.ack.nack().await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user