pub struct AckManager { /* private fields */ }Expand description
ACK manager for tracking pending acknowledgments.
Implementations§
Source§impl AckManager
impl AckManager
Sourcepub fn with_config(config: AckConfig) -> Self
pub fn with_config(config: AckConfig) -> Self
Creates a new ACK manager with custom configuration.
Sourcepub fn register_pending_ack(
&mut self,
message_id: MessageId,
timeout_ms: Option<u64>,
) -> Result<Option<AckEvictionInfo>>
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 ACKtimeout_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.
Sourcepub fn register_pending_ack_with_priority(
&mut self,
message_id: MessageId,
timeout_ms: Option<u64>,
priority: MessagePriority,
) -> Result<Option<AckEvictionInfo>>
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 ACKtimeout_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.
Sourcepub fn drain_timed_out(&mut self) -> Vec<PendingAck>
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 exceededprune_old_timeouts()for stale entries
Sourcepub fn remove_ack(&mut self, message_id: &MessageId) -> Option<PendingAck>
pub fn remove_ack(&mut self, message_id: &MessageId) -> Option<PendingAck>
Removes an ACK from tracking (e.g., after successful delivery).
Sourcepub fn get_timed_out_acks(&self) -> Vec<MessageId>
pub fn get_timed_out_acks(&self) -> Vec<MessageId>
Sourcepub fn increment_retry_count(&mut self, message_id: &MessageId)
pub fn increment_retry_count(&mut self, message_id: &MessageId)
Updates the retry count for a message.
Sourcepub fn get_pending_ack(&self, message_id: &MessageId) -> Option<&PendingAck>
pub fn get_pending_ack(&self, message_id: &MessageId) -> Option<&PendingAck>
Gets information about a pending ACK.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Gets the number of pending ACKs.
Sourcepub fn is_waiting_for_ack(&self, message_id: &MessageId) -> bool
pub fn is_waiting_for_ack(&self, message_id: &MessageId) -> bool
Checks if a message is waiting for ACK.
Sourcepub fn prune_old_timeouts(&mut self, older_than: Duration)
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.