Skip to main content

InMemoryBroker

Struct InMemoryBroker 

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

Production-ready sharded high-concurrency in-memory MessageBroker implementation.

Implementations§

Source§

impl InMemoryBroker

Inherent implementation of InMemoryBroker.

Source

pub fn new(config: MqConfig) -> Self

Creates a new 64-shard InMemoryBroker governed by config.

§Arguments
  • MqConfig - Queue capacity, retry, and visibility timeout settings.
§Returns
  • Self - Ready in-memory message broker.
Source

pub fn get_config(&self) -> &MqConfig

Returns a reference to this broker’s MqConfig.

§Returns
  • &MqConfig - Active broker configuration.
Source

pub fn drain_dlq(&self, topic: &str) -> Vec<MqMessage>

Drains and returns all dead-lettered messages currently buffered for topic.

§Arguments
  • &str - Base topic name.
§Returns
  • Vec<MqMessage> - All dead-lettered messages in FIFO order.
Source

pub fn dlq_len(&self, topic: &str) -> usize

Returns the number of dead-lettered messages currently buffered for topic.

§Arguments
  • &str - Base topic name.
§Returns
  • usize - Count of messages waiting in the dead-letter queue.
Source

pub fn dlq_name(&self, topic: &str) -> String

Returns the canonical dead-letter topic name for topic using this broker’s config.

§Arguments
  • &str - Base topic name.
§Returns
  • String - Configured dead-letter topic name.

Trait Implementations§

Source§

impl Clone for InMemoryBroker

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for InMemoryBroker

Default construction for InMemoryBroker.

Source§

fn default() -> Self

Constructs a default InMemoryBroker value.

Source§

impl MessageBroker for InMemoryBroker

Implements MessageBroker for InMemoryBroker.

Source§

fn subscribe_group<'a>( &'a self, topic: &'a str, group: &'a str, ) -> BrokerFuture<'a, ()>

Implements the subscribe_group operation on InMemoryBroker.

§Arguments
  • &'a self - Shared reference to a 'a self.
  • &'a str - Shared reference to a 'a str.
  • &'a str - Shared reference to a 'a str.
§Returns
  • BrokerFuture<'a, ()> - A BrokerFuture<'a, ()> value.
Source§

fn publish(&self, message: MqMessage) -> BrokerFuture<'_, u64>

Implements the publish operation on InMemoryBroker.

§Arguments
  • MqMessage - A MqMessage parameter.
§Returns
  • BrokerFuture<'_, u64> - A BrokerFuture<'_, u64> value.
Source§

fn consume<'a>( &'a self, topic: &'a str, group: &'a str, ) -> BrokerFuture<'a, Option<MqDelivery>>

Implements the consume operation on InMemoryBroker.

§Arguments
  • &'a self - Shared reference to a 'a self.
  • &'a str - Shared reference to a 'a str.
  • &'a str - Shared reference to a 'a str.
§Returns
  • BrokerFuture<'a, Option<MqDelivery>> - A BrokerFuture<'a, Option<MqDelivery>> value.
Source§

fn ack(&self, receipt_id: u64) -> BrokerFuture<'_, ()>

Implements the ack operation on InMemoryBroker.

§Arguments
  • u64 - A u64 parameter.
§Returns
  • BrokerFuture<'_, ()> - A BrokerFuture<'_, ()> value.
Source§

fn nack(&self, receipt_id: u64, requeue: bool) -> BrokerFuture<'_, ()>

Implements the nack operation on InMemoryBroker.

§Arguments
  • u64 - A u64 parameter.
  • bool - A boolean (bool).
§Returns
  • BrokerFuture<'_, ()> - A BrokerFuture<'_, ()> value.
Source§

fn stats<'a>( &'a self, topic: &'a str, group: &'a str, ) -> BrokerFuture<'a, MqStats>

Implements the stats operation on InMemoryBroker.

§Arguments
  • &'a self - Shared reference to a 'a self.
  • &'a str - Shared reference to a 'a str.
  • &'a str - Shared reference to a 'a str.
§Returns
  • BrokerFuture<'a, MqStats> - A BrokerFuture<'a, MqStats> value.

Auto Trait Implementations§

§

impl Forget for InMemoryBroker

§

impl Freeze for InMemoryBroker
where *const ArcInner<InMemoryBrokerInner> is !null: Freeze, PhantomData<ArcInner<InMemoryBrokerInner>>: Freeze,

§

impl Move for InMemoryBroker

§

impl RefUnwindSafe for InMemoryBroker

§

impl Send for InMemoryBroker
where Arc<InMemoryBrokerInner>: Send,

§

impl Sync for InMemoryBroker
where Arc<InMemoryBrokerInner>: Sync,

§

impl Unpin for InMemoryBroker
where Arc<InMemoryBrokerInner>: Unpin,

§

impl UnsafeUnpin for InMemoryBroker
where *const ArcInner<InMemoryBrokerInner> is !null: UnsafeUnpin, PhantomData<ArcInner<InMemoryBrokerInner>>: UnsafeUnpin,

§

impl UnwindSafe for InMemoryBroker
where Arc<InMemoryBrokerInner>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.