pub struct LapinTestBroker { /* private fields */ }Expand description
In-process broker for application tests: same descriptors, no RabbitMQ server.
Clones share one router, so a publisher and a subscriber cloned from the same broker see
each other; separate new calls are fully isolated.
§Examples
use ruststream::{Broker, Publisher, Subscriber, OutgoingMessage};
use ruststream_lapin::testing::LapinTestBroker;
let broker = LapinTestBroker::new();
let mut subscriber = broker.subscribe("orders").await?;
broker.publisher().publish(OutgoingMessage::new("orders", b"{}")).await?;Implementations§
Source§impl LapinTestBroker
impl LapinTestBroker
Sourcepub async fn subscribe(
&self,
queue: impl Into<String>,
) -> Result<LapinTestSubscriber, AmqpError>
pub async fn subscribe( &self, queue: impl Into<String>, ) -> Result<LapinTestSubscriber, AmqpError>
Subscribes to queue (exact-name routing, the default-exchange model).
§Errors
Returns AmqpError::InvalidOptions when queue is empty.
Sourcepub fn publisher(&self) -> LapinTestPublisher
pub fn publisher(&self) -> LapinTestPublisher
A publisher into this broker’s router.
Trait Implementations§
Source§impl Broker for LapinTestBroker
impl Broker for LapinTestBroker
Source§impl Clone for LapinTestBroker
impl Clone for LapinTestBroker
Source§fn clone(&self) -> LapinTestBroker
fn clone(&self) -> LapinTestBroker
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LapinTestBroker
impl Debug for LapinTestBroker
Source§impl Default for LapinTestBroker
impl Default for LapinTestBroker
Source§fn default() -> LapinTestBroker
fn default() -> LapinTestBroker
Returns the “default value” for a type. Read more
Source§impl DescribeServer for LapinTestBroker
impl DescribeServer for LapinTestBroker
Source§fn describe_server(&self) -> ServerSpec
fn describe_server(&self) -> ServerSpec
Returns the server coordinates for this broker.
Source§impl Subscribe for LapinTestBroker
impl Subscribe for LapinTestBroker
Source§type Subscriber = LapinTestSubscriber
type Subscriber = LapinTestSubscriber
The subscriber type opened by a by-name subscription.
Source§impl SubscriptionSource<LapinTestBroker> for RabbitQueue
Available on crate feature testing only.
impl SubscriptionSource<LapinTestBroker> for RabbitQueue
Available on crate feature
testing only.Source§type Subscriber = LapinTestSubscriber
type Subscriber = LapinTestSubscriber
The subscriber type this source opens.
Source§async fn subscribe(
self,
broker: &LapinTestBroker,
) -> Result<Self::Subscriber, AmqpError>
async fn subscribe( self, broker: &LapinTestBroker, ) -> Result<Self::Subscriber, AmqpError>
Source§impl TestableBroker for LapinTestBroker
impl TestableBroker for LapinTestBroker
Source§fn install_coordinator(&self, coordinator: Coordinator)
fn install_coordinator(&self, coordinator: Coordinator)
Installs the harness coordinator into this broker’s bus for a test run. Idempotent: a second
install on the same broker is ignored.
Source§fn inject(&self, message: OutgoingMessage<'_>)
fn inject(&self, message: OutgoingMessage<'_>)
Injects a message onto the bus as an external producer would, synchronously (no awaiting).
Routes through the broker’s normal fanout, so it is recorded and counted like any publish.
Source§fn published(&self, name: &str) -> Vec<RawMessage>
fn published(&self, name: &str) -> Vec<RawMessage>
Returns every message published to
name on this broker, in publish order. Backs the
harness’s published::<T>(name) assertions and expect_published.Auto Trait Implementations§
impl Freeze for LapinTestBroker
impl RefUnwindSafe for LapinTestBroker
impl Send for LapinTestBroker
impl Sync for LapinTestBroker
impl Unpin for LapinTestBroker
impl UnsafeUnpin for LapinTestBroker
impl UnwindSafe for LapinTestBroker
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more