Skip to main content

ReliableQueue

Struct ReliableQueue 

Source
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

Source

pub fn new(config: ReliableConfig, dead_letter: Arc<DeadLetterQueue>) -> Self

Create a new reliable queue with the given config and dead letter queue.

Source

pub fn with_defaults(dead_letter: Arc<DeadLetterQueue>) -> Self

Create with default configuration.

Source

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).

Source

pub fn dead_letter_model(&self) -> Option<&Arc<Mutex<DeadLetterModel>>>

Returns a handle to the optional dead-letter model.

Source

pub fn config(&self) -> &ReliableConfig

Get the configuration.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn pending_count(&self) -> usize

Number of currently pending deliveries.

Source

pub fn is_pending(&self, correlation_id: &str) -> bool

Check if a specific correlation ID is pending.

Source

pub fn pending_snapshot(&self) -> Vec<(String, PendingDelivery)>

Get a snapshot of all pending deliveries.

Source

pub fn cancel(&self, correlation_id: &str) -> Option<KernelMessage>

Cancel tracking for a specific message.

Source

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§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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