pub struct ReliableQueue { /* private fields */ }Expand description
Reliable message delivery with acknowledgment tracking.
Tracks pending deliveries by correlation ID. On ack timeout, retries
with exponential backoff. After max_retries, routes to the
dead letter queue.
Implementations§
Source§impl ReliableQueue
impl ReliableQueue
Sourcepub fn new(config: ReliableConfig, dead_letter: Arc<DeadLetterQueue>) -> Self
pub fn new(config: ReliableConfig, dead_letter: Arc<DeadLetterQueue>) -> Self
Create a new reliable queue with the given config and dead letter queue.
Sourcepub fn with_defaults(dead_letter: Arc<DeadLetterQueue>) -> Self
pub fn with_defaults(dead_letter: Arc<DeadLetterQueue>) -> Self
Create with default configuration.
Sourcepub fn with_model(self, model: Arc<Mutex<DeadLetterModel>>) -> Self
pub fn with_model(self, model: Arc<Mutex<DeadLetterModel>>) -> Self
Install a learned
DeadLetterModel on this
queue. With a model installed, Self::check_timeouts and
Self::expire_max_retries route their backoff / discard
decisions through the model. Untrained models fall back to
the hardcoded formulas, so with_model is drop-in safe.
NOTE(eml-swap): wired — Finding #5 (DeadLetterModel).
Sourcepub fn dead_letter_model(&self) -> Option<&Arc<Mutex<DeadLetterModel>>>
pub fn dead_letter_model(&self) -> Option<&Arc<Mutex<DeadLetterModel>>>
Returns a handle to the optional dead-letter model.
Sourcepub fn config(&self) -> &ReliableConfig
pub fn config(&self) -> &ReliableConfig
Get the configuration.
Sourcepub fn register(&self, msg: KernelMessage) -> (String, KernelMessage)
pub fn register(&self, msg: KernelMessage) -> (String, KernelMessage)
Register a message for reliable delivery tracking.
The message must have a correlation_id set. If not, one is
generated. Returns the correlation ID used for tracking.
Sourcepub fn acknowledge(&self, correlation_id: &str) -> Option<DeliveryResult>
pub fn acknowledge(&self, correlation_id: &str) -> Option<DeliveryResult>
Acknowledge receipt of a message by correlation ID.
Returns Some(DeliveryResult::Acknowledged) if the message was
pending, or None if not found (already acked or expired).
Sourcepub fn check_timeouts(&self) -> Vec<(String, KernelMessage)>
pub fn check_timeouts(&self) -> Vec<(String, KernelMessage)>
Check for timed-out deliveries and return messages needing retry.
Returns a list of (correlation_id, message) pairs that have
exceeded their ack deadline and should be retried.
NOTE(eml-swap): wired — Finding #5 (DeadLetterModel). When a
learned model is installed and trained, the next-attempt
ack deadline comes from the model; untrained models fall back
to the existing initial_timeout * backoff_multiplier^attempt
formula bit-for-bit.
Sourcepub fn expire_max_retries(&self) -> Vec<DeliveryResult>
pub fn expire_max_retries(&self) -> Vec<DeliveryResult>
Move deliveries that have exceeded max retries to the dead letter queue.
Returns the list of message IDs that were dead-lettered.
NOTE(eml-swap): wired — Finding #5 (DeadLetterModel). When a
trained DeadLetterModel is installed, the discard decision
consults the model’s should_discard head in addition to the
config’s max_retries ceiling. The untrained fallback matches
today’s “attempts > max_retries” rule exactly.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of currently pending deliveries.
Sourcepub fn is_pending(&self, correlation_id: &str) -> bool
pub fn is_pending(&self, correlation_id: &str) -> bool
Check if a specific correlation ID is pending.
Sourcepub fn pending_snapshot(&self) -> Vec<(String, PendingDelivery)>
pub fn pending_snapshot(&self) -> Vec<(String, PendingDelivery)>
Get a snapshot of all pending deliveries.
Sourcepub fn cancel(&self, correlation_id: &str) -> Option<KernelMessage>
pub fn cancel(&self, correlation_id: &str) -> Option<KernelMessage>
Cancel tracking for a specific message.
Sourcepub fn timeout_for_attempt(&self, attempt: u32) -> Duration
pub fn timeout_for_attempt(&self, attempt: u32) -> Duration
Calculate the timeout for a given attempt number.
Uses the same EML-aware dispatch as Self::check_timeouts
so external callers observing the policy see the same delays
the queue would actually wait.
Auto Trait Implementations§
impl !RefUnwindSafe for ReliableQueue
impl Freeze for ReliableQueue
impl Send for ReliableQueue
impl Sync for ReliableQueue
impl Unpin for ReliableQueue
impl UnsafeUnpin for ReliableQueue
impl UnwindSafe for ReliableQueue
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more