pub struct MemoryBackend { /* private fields */ }Expand description
An in-memory Backend. Cloning gives another handle onto the same state.
let backend = MemoryBackend::new();
let same_state = backend.clone();
assert_eq!(same_state.pending("nothing.here"), 0);Implementations§
Source§impl MemoryBackend
impl MemoryBackend
Sourcepub fn new() -> MemoryBackend
pub fn new() -> MemoryBackend
Create an empty backend with no queues declared.
Sourcepub fn pending(&self, queue: &str) -> usize
pub fn pending(&self, queue: &str) -> usize
Number of messages waiting in queue.
Messages that were handed to a consumer but not yet settled are not counted, and neither are delayed publishes whose delay has not elapsed.
Sourcepub fn acked(&self, queue: &str) -> Vec<Envelope>
pub fn acked(&self, queue: &str) -> Vec<Envelope>
Envelopes that were acked on queue, in ack order.
A successful Delivery::retry acks the original envelope, so it shows up here
too (the rescheduled copy arrives separately with attempt + 1).
Sourcepub fn deferred(&self, queue: &str) -> usize
pub fn deferred(&self, queue: &str) -> usize
Number of deferred envelopes still sitting in queue’s hold.
These are the ones Backend::defer (or Delivery::defer) accepted but
whose delay has not elapsed: they are not pending yet and no consumer can see
them. The count drops back to zero as each hold expires or, if the backend
was closed in the meantime, as each held envelope is dropped.
Sourcepub fn dead_letters(&self, queue: &str) -> Vec<(Envelope, String)>
pub fn dead_letters(&self, queue: &str) -> Vec<(Envelope, String)>
Envelopes that were dead-lettered on queue, with the reason given.
Sourcepub fn queue_names(&self) -> Vec<String>
pub fn queue_names(&self) -> Vec<String>
Names of every declared (or implicitly created) queue.
Sourcepub fn queue_config(&self, queue: &str) -> Option<QueueConfig>
pub fn queue_config(&self, queue: &str) -> Option<QueueConfig>
Config recorded for queue by the first declare call, if any.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether Backend::close has been called.
Trait Implementations§
Source§impl Backend for MemoryBackend
impl Backend for MemoryBackend
Source§fn declare<'life0, 'life1, 'async_trait>(
&'life0 self,
queues: &'life1 [QueueConfig],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
fn declare<'life0, 'life1, 'async_trait>(
&'life0 self,
queues: &'life1 [QueueConfig],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
Source§fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
envelope: &'life1 Envelope,
delay: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
envelope: &'life1 Envelope,
delay: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
envelope to envelope.queue, optionally delayed.Source§fn defer<'life0, 'life1, 'async_trait>(
&'life0 self,
envelope: &'life1 Envelope,
delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
fn defer<'life0, 'life1, 'async_trait>(
&'life0 self,
envelope: &'life1 Envelope,
delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
envelope into a hold that releases it onto envelope.queue after
delay. This is the publish half of Delivery::defer, also used by
crate::Producer::defer. Read moreSource§fn consume<'life0, 'life1, 'async_trait>(
&'life0 self,
queue: &'life1 QueueConfig,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Box<dyn Delivery>, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
fn consume<'life0, 'life1, 'async_trait>(
&'life0 self,
queue: &'life1 QueueConfig,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Box<dyn Delivery>, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MemoryBackend: 'async_trait,
queue with the given prefetch. The stream ends when the
backend is closed or the connection is lost.Source§impl Clone for MemoryBackend
impl Clone for MemoryBackend
Source§fn clone(&self) -> MemoryBackend
fn clone(&self) -> MemoryBackend
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more