pub struct MessageMetadata {
pub received_at: DateTime<Utc>,
pub attempt: u32,
pub source: String,
pub correlation_id: Option<String>,
pub routing_key: Option<String>,
}Expand description
Metadata associated with a message.
Fields§
§received_at: DateTime<Utc>When the message was received
attempt: u32Number of processing attempts
source: StringSource of the message (queue name, stream name, etc.)
correlation_id: Option<String>Optional correlation ID for distributed tracing
routing_key: Option<String>RabbitMQ routing key (if applicable)
Implementations§
Source§impl MessageMetadata
impl MessageMetadata
Sourcepub fn new(source: impl Into<String>) -> Self
pub fn new(source: impl Into<String>) -> Self
Create new message metadata with current timestamp.
Sourcepub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
pub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
Set the correlation ID for distributed tracing.
Sourcepub fn with_routing_key(self, routing_key: impl Into<String>) -> Self
pub fn with_routing_key(self, routing_key: impl Into<String>) -> Self
Set the routing key (for RabbitMQ messages).
Sourcepub fn increment_attempt(&mut self)
pub fn increment_attempt(&mut self)
Increment the attempt counter.
Trait Implementations§
Source§impl Clone for MessageMetadata
impl Clone for MessageMetadata
Source§fn clone(&self) -> MessageMetadata
fn clone(&self) -> MessageMetadata
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessageMetadata
impl Debug for MessageMetadata
Source§impl<'de> Deserialize<'de> for MessageMetadata
impl<'de> Deserialize<'de> for MessageMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MessageMetadata
impl RefUnwindSafe for MessageMetadata
impl Send for MessageMetadata
impl Sync for MessageMetadata
impl Unpin for MessageMetadata
impl UnsafeUnpin for MessageMetadata
impl UnwindSafe for MessageMetadata
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
Mutably borrows from an owned value. Read more