pub struct BusMessage {
pub id: Uuid,
pub message_type: MessageType,
pub source: Uuid,
pub payload: String,
pub timestamp: i64,
pub correlation_id: Option<Uuid>,
pub headers: HashMap<String, String>,
}Expand description
A message that flows through the bus.
Fields§
§id: UuidUnique message identifier
message_type: MessageTypeMessage type / topic
source: UuidSource node that sent the message
payload: StringSerialized payload
timestamp: i64Unix timestamp when the message was created
correlation_id: Option<Uuid>Optional correlation ID for request-reply patterns
headers: HashMap<String, String>Message headers (metadata)
Implementations§
Source§impl BusMessage
impl BusMessage
Sourcepub fn new(message_type: MessageType, source: Uuid, payload: &str) -> Self
pub fn new(message_type: MessageType, source: Uuid, payload: &str) -> Self
Creates a new bus message.
Sourcepub fn with_correlation(self, correlation_id: Uuid) -> Self
pub fn with_correlation(self, correlation_id: Uuid) -> Self
Sets a correlation ID for request-reply patterns.
Sourcepub fn with_header(self, key: &str, value: &str) -> Self
pub fn with_header(self, key: &str, value: &str) -> Self
Adds a header to the message.
Trait Implementations§
Source§impl Clone for BusMessage
impl Clone for BusMessage
Source§fn clone(&self) -> BusMessage
fn clone(&self) -> BusMessage
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 BusMessage
impl Debug for BusMessage
Source§impl<'de> Deserialize<'de> for BusMessage
impl<'de> Deserialize<'de> for BusMessage
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 BusMessage
impl RefUnwindSafe for BusMessage
impl Send for BusMessage
impl Sync for BusMessage
impl Unpin for BusMessage
impl UnsafeUnpin for BusMessage
impl UnwindSafe for BusMessage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
Wrap the input message
T in a tonic::Request