pub struct MessageEnvelope<T> {
pub payload: T,
pub metadata: MessageMetadata,
}Expand description
Message envelope that wraps the actual payload with metadata
Fields§
§payload: TThe actual message payload
metadata: MessageMetadataMessage metadata
Implementations§
Source§impl<T> MessageEnvelope<T>
impl<T> MessageEnvelope<T>
Sourcepub fn new(payload: T, source_queue: &str) -> Self
pub fn new(payload: T, source_queue: &str) -> Self
Create a new message envelope with the given payload
Sourcepub fn with_source(
payload: T,
queue: &str,
exchange: Option<&str>,
routing_key: Option<&str>,
publisher: Option<&str>,
) -> Self
pub fn with_source( payload: T, queue: &str, exchange: Option<&str>, routing_key: Option<&str>, publisher: Option<&str>, ) -> Self
Create envelope with source details
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Set the maximum number of retries
Sourcepub fn with_header(self, key: &str, value: &str) -> Self
pub fn with_header(self, key: &str, value: &str) -> Self
Add a custom header
Sourcepub fn is_retry_exhausted(&self) -> bool
pub fn is_retry_exhausted(&self) -> bool
Check if this message has exceeded its retry limit
Sourcepub fn is_first_attempt(&self) -> bool
pub fn is_first_attempt(&self) -> bool
Check if this is the first attempt (not a retry)
Sourcepub fn next_retry_attempt(&self) -> u32
pub fn next_retry_attempt(&self) -> u32
Get the next retry attempt number
Sourcepub fn with_error(
self,
error: &str,
error_type: ErrorType,
context: Option<&str>,
) -> Self
pub fn with_error( self, error: &str, error_type: ErrorType, context: Option<&str>, ) -> Self
Record an error and create a new envelope for retry
Sourcepub fn last_error(&self) -> Option<&ErrorRecord>
pub fn last_error(&self) -> Option<&ErrorRecord>
Get the last error if any
Sourcepub fn errors_by_type(&self, error_type: &ErrorType) -> Vec<&ErrorRecord>
pub fn errors_by_type(&self, error_type: &ErrorType) -> Vec<&ErrorRecord>
Get all errors of a specific type
Sourcepub fn get_failure_summary(&self) -> String
pub fn get_failure_summary(&self) -> String
Get a summary string for dead letter analysis
Trait Implementations§
Source§impl<T: Clone> Clone for MessageEnvelope<T>
impl<T: Clone> Clone for MessageEnvelope<T>
Source§fn clone(&self) -> MessageEnvelope<T>
fn clone(&self) -> MessageEnvelope<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for MessageEnvelope<T>
impl<T: Debug> Debug for MessageEnvelope<T>
Source§impl<'de, T> Deserialize<'de> for MessageEnvelope<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for MessageEnvelope<T>where
T: Deserialize<'de>,
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<T> Freeze for MessageEnvelope<T>where
T: Freeze,
impl<T> RefUnwindSafe for MessageEnvelope<T>where
T: RefUnwindSafe,
impl<T> Send for MessageEnvelope<T>where
T: Send,
impl<T> Sync for MessageEnvelope<T>where
T: Sync,
impl<T> Unpin for MessageEnvelope<T>where
T: Unpin,
impl<T> UnwindSafe for MessageEnvelope<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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