pub struct DistributedMessage {
pub id: u64,
pub priority: MessagePriority,
pub payload: Vec<u8>,
pub enqueued_at: Instant,
pub ttl: Option<Duration>,
pub source: String,
pub destination: String,
}Expand description
An envelope wrapping a message payload for the distributed queue.
Fields§
§id: u64Unique message identifier.
priority: MessagePriorityPriority of this message.
payload: Vec<u8>Opaque byte payload.
enqueued_at: InstantWhen the message was enqueued.
ttl: Option<Duration>Optional TTL: message is expired after this duration.
source: StringSource node identifier.
destination: StringDestination node identifier.
Implementations§
Source§impl DistributedMessage
impl DistributedMessage
Sourcepub fn new(
id: u64,
priority: MessagePriority,
payload: Vec<u8>,
source: impl Into<String>,
destination: impl Into<String>,
) -> Self
pub fn new( id: u64, priority: MessagePriority, payload: Vec<u8>, source: impl Into<String>, destination: impl Into<String>, ) -> Self
Create a new message.
Sourcepub fn is_expired(&self, now: Instant) -> bool
pub fn is_expired(&self, now: Instant) -> bool
Return true if the message’s TTL has elapsed relative to now.
Messages without a TTL never expire.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Payload length in bytes.
Trait Implementations§
Source§impl Clone for DistributedMessage
impl Clone for DistributedMessage
Source§fn clone(&self) -> DistributedMessage
fn clone(&self) -> DistributedMessage
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 moreAuto Trait Implementations§
impl Freeze for DistributedMessage
impl RefUnwindSafe for DistributedMessage
impl Send for DistributedMessage
impl Sync for DistributedMessage
impl Unpin for DistributedMessage
impl UnsafeUnpin for DistributedMessage
impl UnwindSafe for DistributedMessage
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,
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