pub struct MessageQueue { /* private fields */ }Expand description
A bounded, priority-ordered distributed message queue.
Implementations§
Source§impl MessageQueue
impl MessageQueue
Sourcepub fn enqueue(&mut self, message: DistributedMessage) -> bool
pub fn enqueue(&mut self, message: DistributedMessage) -> bool
Enqueue a message.
Returns false and increments the dropped counter when the queue is
at capacity.
Sourcepub fn dequeue(&mut self) -> Option<DistributedMessage>
pub fn dequeue(&mut self) -> Option<DistributedMessage>
Dequeue the highest-priority message, or None if the queue is empty.
Sourcepub fn peek_priority(&self) -> Option<MessagePriority>
pub fn peek_priority(&self) -> Option<MessagePriority>
Peek at the priority of the next message without removing it.
Sourcepub fn enqueued_total(&self) -> u64
pub fn enqueued_total(&self) -> u64
Total messages successfully enqueued since creation.
Sourcepub fn dropped_total(&self) -> u64
pub fn dropped_total(&self) -> u64
Total messages dropped due to capacity overflow.
Sourcepub fn drain_expired(&mut self, now: Instant) -> usize
pub fn drain_expired(&mut self, now: Instant) -> usize
Drain all expired messages (as of now) from the queue, returning the
count of messages removed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MessageQueue
impl RefUnwindSafe for MessageQueue
impl Send for MessageQueue
impl Sync for MessageQueue
impl Unpin for MessageQueue
impl UnsafeUnpin for MessageQueue
impl UnwindSafe for MessageQueue
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> 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