Skip to main content

InMemoryQueueSource

Struct InMemoryQueueSource 

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

Process-local QueueSource for tests, examples, and single-process deployments.

publish appends a message; publishing one id twice models a broker’s duplicate delivery. A pulled message is leased for the visibility timeout (default 30 seconds).

Implementations§

Source§

impl InMemoryQueueSource

Source

pub fn new(name: impl Into<String>) -> Self

Creates an empty source named name that reads the system clock.

Source

pub fn with_visibility_timeout(self, timeout: Duration) -> Self

Sets how long a pulled message stays leased before it is redelivered.

Source

pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self

Sets the clock that decides lease expiry and nack delays.

Source

pub fn publish(&self, id: impl Into<String>, body: impl Into<Vec<u8>>)

Appends a message.

Source

pub fn publish_with_attributes( &self, id: impl Into<String>, body: impl Into<Vec<u8>>, attributes: HashMap<String, String>, )

Appends a message with attributes.

Source

pub fn unacked(&self) -> usize

Messages not yet acked, leased or not.

Source

pub fn acked(&self) -> Vec<String>

The ids of acked messages, in ack order.

Trait Implementations§

Source§

impl Debug for InMemoryQueueSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl QueueSource for InMemoryQueueSource

Source§

fn name(&self) -> &str

A stable name for this source, used in idempotency keys and logs.
Source§

fn pull<'life0, 'async_trait>( &'life0 self, max_messages: usize, wait: Duration, ) -> Pin<Box<dyn Future<Output = Result<Vec<QueueMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Leases up to max_messages messages, waiting up to wait for the first one. Read more
Source§

fn ack<'life0, 'life1, 'async_trait>( &'life0 self, receipt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes the message leased under receipt. Read more
Source§

fn nack<'life0, 'life1, 'async_trait>( &'life0 self, receipt: &'life1 str, redeliver_after: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the message leased under receipt for redelivery after redeliver_after. Read more

Auto Trait Implementations§

§

impl !Freeze for InMemoryQueueSource

§

impl !RefUnwindSafe for InMemoryQueueSource

§

impl !UnwindSafe for InMemoryQueueSource

§

impl Forget for InMemoryQueueSource

§

impl Move for InMemoryQueueSource

§

impl Send for InMemoryQueueSource
where RawVecInner: Send, Mutex<QueueTable>: Send, AtomicUsize: Send, Mutex<LinkedList<Waiter>>: Send, Arc<dyn Clock>: Send,

§

impl Sync for InMemoryQueueSource
where RawVecInner: Sync, Mutex<QueueTable>: Sync, AtomicUsize: Sync, Mutex<LinkedList<Waiter>>: Sync, Arc<dyn Clock>: Sync,

§

impl Unpin for InMemoryQueueSource
where *const u8 is !null: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, NonZero<i32>: Unpin, Utc: Unpin, Align8<usize>: Unpin, *const Waiter is !null: Unpin, Arc<dyn Clock>: Unpin,

§

impl UnsafeUnpin for InMemoryQueueSource
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, PhantomData<Stored>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, Align8<usize>: UnsafeUnpin, *const Waiter is !null: UnsafeUnpin, *const ArcInner<dyn Clock> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Clock>>: UnsafeUnpin,

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