Skip to content

Commit

Permalink
Allow retrying Delivery::{ack, nack}
Browse files Browse the repository at this point in the history
… by returning `self` on failure.
  • Loading branch information
svix-jplatte committed Feb 7, 2024
1 parent 7210d81 commit ca9ce8b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions omniqueue/src/queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,22 @@ pub struct Delivery {
impl Delivery {
/// Acknowledges the receipt and successful processing of this [`Delivery`].
///
/// On failure, `self` is returned alongside the error to allow retrying.
///
/// The exact nature of this will vary per backend, but usually it ensures that the same message
/// is not reprocessed.
pub async fn ack(mut self) -> Result<(), QueueError> {
self.acker.ack().await
pub async fn ack(mut self) -> Result<(), (QueueError, Self)> {
self.acker.ack().await.map_err(|e| (e, self))
}

/// Explicitly does not Acknowledge the successful processing of this [`Delivery`].
///
/// On failure, `self` is returned alongside the error to allow retrying.
///
/// The exact nature of this will vary by backend, but usually it ensures that the same message
/// is either reinserted into the same queue or is sent to a separate collection.
pub async fn nack(mut self) -> Result<(), QueueError> {
self.acker.nack().await
pub async fn nack(mut self) -> Result<(), (QueueError, Self)> {
self.acker.nack().await.map_err(|e| (e, self))
}

/// This method will deserialize the contained bytes using the configured decoder.
Expand Down

0 comments on commit ca9ce8b

Please sign in to comment.