pub struct PubSubMessage { /* private fields */ }Expand description
A message delivered by a PubSubSubscriber.
ack and nack(requeue = true) are native. nack(requeue = false) acknowledges: Pub/Sub
has no “drop without redelivery” beyond acknowledgement - dead-lettering is the
subscription’s dead-letter policy, driven by repeated nacks and expired deadlines, not a
per-message verb. The exception is the last delivery that policy allows, where a rejection is
exactly how the message reaches the dead-letter topic; a delivery there is rejected rather
than acknowledged. The policy is the one the subscription carries when it opens, declared at
the mount site or set by an operator. On an exactly-once subscription the confirmed forms are
used, so Ok from ack means the broker accepted it.
Trait Implementations§
Source§impl Debug for PubSubMessage
impl Debug for PubSubMessage
Source§impl IncomingMessage for PubSubMessage
impl IncomingMessage for PubSubMessage
Source§fn redelivery_count(&self) -> Option<u64>
fn redelivery_count(&self) -> Option<u64>
The delivery attempt the service reports, counting this delivery.
Pub/Sub sends it only where the subscription has a dead-letter policy, so a subscription without one reports no count. It is the only count a delivery of this crate carries: nothing here publishes a retry copy, so the framework’s own header never appears beside it, and the cap the count would be read against is the subscription’s to apply.
Source§fn supports_nack_after(&self) -> bool
fn supports_nack_after(&self) -> bool
Pub/Sub has no delayed nack of its own, so this crate holds the delivery instead. The client keeps extending the ack deadline of a delivery nothing has settled, which is what makes holding one a real delay rather than a lost message.
Source§fn nack_after(
self,
delay: Duration,
) -> impl Future<Output = Result<(), AckError>> + Send
fn nack_after( self, delay: Duration, ) -> impl Future<Output = Result<(), AckError>> + Send
Holds the delivery for delay, then rejects it so the subscription redelivers.
The delivery stays leased while it is held: the client extends its ack deadline in the
background for as long as nothing has settled it, up to
GooglePubSub::max_lease. The wait runs on a task of its
own, so the subscription keeps dispatching; the delivery counts against the subscription’s
outstanding messages until it comes back, which is what it does against the service too.
If the process dies while a delivery is held, the lease stops being extended and the subscription redelivers on its own once it expires. The delay is lost there, not the message.
§Errors
Returns AckError::Broker carrying PubSubError::DelayBeyondLease when delay
outlives the subscription’s maximum lease, because the delivery would come back before it
elapsed. The check is at the call because a handler names the delay while it runs.
Source§async fn ack(self) -> Result<(), AckError>
async fn ack(self) -> Result<(), AckError>
Source§async fn nack(self, requeue: bool) -> Result<(), AckError>
async fn nack(self, requeue: bool) -> Result<(), AckError>
requeue is true the broker should
redeliver according to its own retry policy; when false it should drop or dead-letter
the message. Read moreSource§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
None when the
message carries no key. Read moreSource§fn decode_error(&self) -> Option<&CodecError>
fn decode_error(&self) -> Option<&CodecError>
None when it read the delivery
whole. Read moreSource§impl Partitioned for PubSubMessage
impl Partitioned for PubSubMessage
Source§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
None if the broker should pick a partition.Auto Trait Implementations§
impl !Freeze for PubSubMessage
impl !RefUnwindSafe for PubSubMessage
impl !UnwindSafe for PubSubMessage
impl Send for PubSubMessage
impl Sync for PubSubMessage
impl Unpin for PubSubMessage
impl UnsafeUnpin for PubSubMessage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> 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> ⓘ
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> ⓘ
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 moreSource§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