Skip to main content

AckManager

Struct AckManager 

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

ACK manager for tracking pending acknowledgments.

Implementations§

Source§

impl AckManager

Source

pub fn new() -> Self

Creates a new ACK manager with default configuration.

Source

pub fn with_config(config: AckConfig) -> Self

Creates a new ACK manager with custom configuration.

Source

pub fn register_pending_ack( &mut self, message_id: MessageId, timeout_ms: Option<u64>, ) -> Result<Option<AckEvictionInfo>>

Registers a message as waiting for ACK.

§Arguments
  • message_id - ID of the message waiting for ACK
  • timeout_ms - Optional custom timeout (uses default if None)
§Returns

Returns Ok(Some(info)) if a lower-priority ACK was evicted to make room, Ok(None) if no eviction was needed, or Err if capacity is full and no lower-priority ACK exists to evict.

Source

pub fn register_pending_ack_with_priority( &mut self, message_id: MessageId, timeout_ms: Option<u64>, priority: MessagePriority, ) -> Result<Option<AckEvictionInfo>>

Registers a message as waiting for ACK with specified priority.

§Arguments
  • message_id - ID of the message waiting for ACK
  • timeout_ms - Optional custom timeout (uses default if None)
  • priority - Message priority for eviction decisions
§Returns

Returns Ok(Some(info)) if a lower-priority ACK was evicted to make room, Ok(None) if no eviction was needed, or Err if capacity is full and no lower-priority ACK exists to evict.

Source

pub fn drain_timed_out(&mut self) -> Vec<PendingAck>

Returns all ACKs that have timed out and marks them as TimedOut.

Note: This does NOT remove entries from the map. Entries are kept so that:

  • increment_retry_count() can reset them when the message is retried
  • Late ACKs can still be matched via remove_ack()

Entries are eventually removed by:

  • remove_ack() when ACK is received or max retries exceeded
  • prune_old_timeouts() for stale entries
Source

pub fn remove_ack(&mut self, message_id: &MessageId) -> Option<PendingAck>

Removes an ACK from tracking (e.g., after successful delivery).

Source

pub fn get_timed_out_acks(&self) -> Vec<MessageId>

Gets all timed out ACKs.

§Returns

Returns a vector of message IDs that have timed out.

Source

pub fn increment_retry_count(&mut self, message_id: &MessageId)

Updates the retry count for a message.

Source

pub fn get_pending_ack(&self, message_id: &MessageId) -> Option<&PendingAck>

Gets information about a pending ACK.

Source

pub fn pending_count(&self) -> usize

Gets the number of pending ACKs.

Source

pub fn is_waiting_for_ack(&self, message_id: &MessageId) -> bool

Checks if a message is waiting for ACK.

Source

pub fn prune_old_timeouts(&mut self, older_than: Duration)

Removes all ACKs with TimedOut status that are older than a given duration.

This helps prevent unbounded memory growth.

Trait Implementations§

Source§

impl Default for AckManager

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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