pub struct ExactlyOnce { /* private fields */ }Expand description
A handler for exactly-once delivery.
Implementations§
Source§impl ExactlyOnce
impl ExactlyOnce
Sourcepub async fn confirmed_ack(self) -> Result<(), AckError>
pub async fn confirmed_ack(self) -> Result<(), AckError>
Strongly acknowledge the message associated with this handler.
use google_cloud_pubsub::model::Message;
async fn on_message(m: Message, h: ExactlyOnce) {
match h.confirmed_ack().await {
Ok(()) => println!("Confirmed ack for message={m:?}. The message will not be redelivered."),
Err(e) => println!("Failed to confirm ack for message={m:?} with error={e:?}"),
}
}If the result is an Ok, the message is guaranteed not to be delivered
again.
If the result is an Err, the message may be redelivered, but this is
not guaranteed. If no redelivery occurs a sufficient interval after an
error, the acknowledgement likely succeeded.
Sourcepub async fn confirmed_nack(self) -> Result<(), AckError>
pub async fn confirmed_nack(self) -> Result<(), AckError>
Rejects the message associated with this handler and waits for confirmation.
use google_cloud_pubsub::model::Message;
async fn on_message(m: Message, h: ExactlyOnce) {
match h.confirmed_nack().await {
Ok(()) => println!("Confirmed nack for message={m:?}. The message will be redelivered."),
Err(e) => println!("Failed to confirm nack for message={m:?} with error={e:?}"),
}
}If the result is an Ok, the message is guaranteed to be immediately
considered for redelivery. If an error occurs, the message will still
be redelivered, but it may be held for the remainder of its
max_lease_extension.
Sourcepub fn delivery_attempt(&self) -> Option<i32>
pub fn delivery_attempt(&self) -> Option<i32>
Returns the delivery attempt count for this message, if available.
§Example
fn on_message(h: ExactlyOnce) {
match h.delivery_attempt() {
Some(i) => println!("Delivery attempt: {i}"),
None => println!("Delivery attempt: unknown"),
}
}This returns None if dead-letter topics are not configured on the
subscription.
Trait Implementations§
Source§impl Debug for ExactlyOnce
impl Debug for ExactlyOnce
Auto Trait Implementations§
impl Freeze for ExactlyOnce
impl !RefUnwindSafe for ExactlyOnce
impl Send for ExactlyOnce
impl Sync for ExactlyOnce
impl Unpin for ExactlyOnce
impl UnsafeUnpin for ExactlyOnce
impl !UnwindSafe for ExactlyOnce
Blanket Implementations§
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request