pub enum NatsMessage {
Core(Box<CoreMessage>),
JetStream(Box<JetStreamMessage>),
}Expand description
A NATS delivery. Two flavours: core NATS (no ack) and JetStream (real ack/nack/redelivery).
Both variants are boxed to keep the enum compact; the wrapped async_nats messages are large.
Variants§
Core(Box<CoreMessage>)
A core NATS subject delivery. Acknowledgement is not supported.
JetStream(Box<JetStreamMessage>)
A JetStream pull-consumer delivery with full ack support.
Trait Implementations§
Source§impl BuildContext<NatsMessage> for JetStreamContext
impl BuildContext<NatsMessage> for JetStreamContext
Source§fn build(msg: &NatsMessage) -> Self
fn build(msg: &NatsMessage) -> Self
msg.Source§impl Debug for NatsMessage
impl Debug for NatsMessage
Source§impl IncomingMessage for NatsMessage
impl IncomingMessage for NatsMessage
Source§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
The PARTITION_KEY_HEADER value the sender set, which the runtime’s keyed worker lanes
(workers(n, by_key)) order by.
Source§fn redelivery_count(&self) -> Option<u64>
fn redelivery_count(&self) -> Option<u64>
How many times the server has delivered this message, counting this one.
A JetStream consumer keeps that count and reports it on every delivery, so a cap
declared at the mount site counts the server’s own redeliveries - an ack_wait that ran
out, a negative acknowledgement - and not only the copies this process published. Core
NATS neither stores a message nor redelivers one, so a core delivery has no count and the
framework’s retry-count header is the whole tally.
Source§fn supports_nack_after(&self) -> bool
fn supports_nack_after(&self) -> bool
Whether this delivery can honor a native delayed redelivery.
true for every JetStream delivery: the protocol carries the delay in the negative
acknowledgement itself, so no opt-in infrastructure is needed. Core NATS has no
acknowledgement at all, so a core delivery reports false and the runtime applies its
broker-agnostic deferred re-publish instead.
Source§async fn nack_after(self, delay: Duration) -> Result<(), AckError>
async fn nack_after(self, delay: Duration) -> Result<(), AckError>
Redelivers this message no sooner than delay, natively: JetStream’s negative
acknowledgement takes the delay as its argument (-NAK {"delay": ns}), so the server holds
the message for that long and then redelivers it on this consumer. Nothing is re-published
and no copy is made, so the delivery count, the stream sequence, and the payload all stay
the ones the message was first delivered with.
§Errors
Returns AckError::Unsupported on a core (non-JetStream) delivery, and
AckError::Broker when the acknowledgement cannot be sent.
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 decode_error(&self) -> Option<&CodecError>
fn decode_error(&self) -> Option<&CodecError>
None when it read the delivery
whole. Read moreSource§impl Partitioned for NatsMessage
Partitioned lets the workers(N, by_key) runtime feature assign a dispatch lane based on
a well-known message header. NATS has no native partition concept, so the key travels as the
PARTITION_KEY_HEADER header value and the sender is responsible for setting it.
impl Partitioned for NatsMessage
Partitioned lets the workers(N, by_key) runtime feature assign a dispatch lane based on
a well-known message header. NATS has no native partition concept, so the key travels as the
PARTITION_KEY_HEADER header value and the sender is responsible for setting it.
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 !RefUnwindSafe for NatsMessage
impl !UnwindSafe for NatsMessage
impl Freeze for NatsMessage
impl Send for NatsMessage
impl Sync for NatsMessage
impl Unpin for NatsMessage
impl UnsafeUnpin for NatsMessage
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> 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 more