Skip to main content

RetryQueue

Struct RetryQueue 

Source
pub struct RetryQueue { /* private fields */ }
Expand description

Retry queue for managing message retries with exponential backoff.

Implementations§

Source§

impl RetryQueue

Source

pub fn new() -> Self

Creates a new retry queue with default configuration.

Source

pub fn with_config(config: RetryConfig) -> Self

Creates a new retry queue with custom configuration.

Source

pub fn enqueue( &mut self, message: Message, retry_count: u32, ) -> Option<DateTime<Utc>>

Adds a message to the retry queue.

The retry queue is a pure scheduling mechanism — it does not enforce a retry limit. ACK-level retry limits are enforced by the ACK manager in the protocol layer.

Duplicate messages (same ID already in queue) are silently ignored.

§Arguments
  • message - The message to queue for retry
  • retry_count - Current retry count (used for backoff calculation)
§Returns

The absolute time the retry is scheduled for, or None if the message was already queued (nothing was scheduled).

Source

pub fn enqueue_with_delay( &mut self, message: Message, retry_count: u32, delay_ms: u64, ) -> Option<DateTime<Utc>>

Adds a message to the retry queue with an explicit delay, bypassing the backoff formula.

Used for reachability probes toward peers an authoritative relay verdict reported unreachable, where the interval is driven by per-peer escalation rather than this message’s retry count.

Duplicate messages (same ID already in queue) are silently ignored; None means nothing was scheduled.

Source

pub fn dequeue_ready(&mut self) -> Option<RetryEntry>

Dequeues the next message that is ready for retry.

§Returns

Returns Some(RetryEntry) if a message is ready, None otherwise.

Source

pub fn peek_ready(&self) -> Vec<&RetryEntry>

Gets all messages ready for retry without removing them.

Source

pub fn remove(&mut self, message_id: &str) -> bool

Removes a message from the queue (e.g., after successful delivery).

Source

pub fn cleanup_expired(&mut self) -> usize

Cleans up expired messages that exceeded their max lifetime.

§Returns

Returns the number of expired messages removed.

Source

pub fn len(&self) -> usize

Gets the number of messages in the queue.

Source

pub fn is_empty(&self) -> bool

Checks if the queue is empty.

Source

pub fn contains(&self, message_id: &str) -> bool

Checks if a message is in the queue.

Source

pub fn drain_all(&mut self) -> Vec<RetryEntry>

Drains all entries from the queue, ignoring retry_at timing.

Returns entries in priority order (earliest retry_at first, then highest message priority). Used for immediate flush when transport becomes available.

Source

pub fn time_until_next_retry(&self) -> Option<Duration>

Gets the time until the next retry is ready.

§Returns

Returns Some(Duration) if there are pending retries, None if empty.

Source

pub fn stats(&self) -> RetryQueueStats

Gets statistics about the retry queue.

Trait Implementations§

Source§

impl Default for RetryQueue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more