Skip to main content

RedisTestBroker

Struct RedisTestBroker 

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

In-process Redis broker used for handler-level tests.

publish matches stream keys exactly (Redis Streams have no wildcard subjects) and hands the message to every matching subscriber’s channel; ack/nack(requeue = false) consume the delivery and nack(requeue = true) re-sends it to the same subscriber’s queue.

Broker-specific edge cases (consumer-group cursors, XAUTOCLAIM redelivery, idle reclaim, MAXLEN trimming, dead-letter routing) are intentionally NOT simulated. Use a real Redis server for those scenarios.

Implementations§

Source§

impl RedisTestBroker

Source

pub fn new() -> Self

Constructs a fresh, isolated test broker. Equivalent to Self::default.

Source

pub async fn subscribe( &self, key: impl Into<String>, ) -> Result<RedisTestSubscriber, RedisError>

Opens a subscription on the stream key. Mirrors the public surface of crate::RedisBroker::subscribe; in handler-stub mode only the key is used for routing (no consumer-group bookkeeping).

§Errors

Returns RedisError::Subscribe when key is empty.

Source

pub fn publisher(&self) -> RedisTestPublisher

Returns a publisher bound to this broker. Cheap to clone.

Trait Implementations§

Source§

impl Broker for RedisTestBroker

Source§

type Error = RedisError

The error type returned by broker-level operations.
Source§

async fn connect(&self) -> Result<(), Self::Error>

Establishes the connection to the broker. Idempotent: calling multiple times must not open additional sockets. Read more
Source§

async fn shutdown(&self) -> Result<(), Self::Error>

Closes the broker connection, flushing in-flight publishes and stopping background tasks. Read more
Source§

impl Clone for RedisTestBroker

Source§

fn clone(&self) -> RedisTestBroker

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 Debug for RedisTestBroker

Source§

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

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

impl Default for RedisTestBroker

Source§

fn default() -> RedisTestBroker

Returns the “default value” for a type. Read more
Source§

impl DescribeServer for RedisTestBroker

Source§

fn describe_server(&self) -> ServerSpec

Returns the server coordinates for this broker.
Source§

impl Subscribe for RedisTestBroker

Source§

type Subscriber = RedisTestSubscriber

The subscriber type opened by a by-name subscription.
Source§

async fn subscribe(&self, name: &str) -> Result<Self::Subscriber, Self::Error>

Opens a subscription to name, producing this broker’s Subscriber. Read more
Source§

impl SubscriptionSource<RedisTestBroker> for RedisList

Available on crate feature testing only.
Source§

type Subscriber = RedisTestSubscriber

The subscriber type this source opens.
Source§

fn name(&self) -> &str

The name (subject / channel) this subscription binds to. Read more
Source§

async fn subscribe( self, broker: &RedisTestBroker, ) -> Result<Self::Subscriber, RedisError>

Opens the subscription against broker. Called once, after Broker::connect. Read more
Source§

impl SubscriptionSource<RedisTestBroker> for RedisPubSub

Available on crate feature testing only.
Source§

type Subscriber = RedisTestSubscriber

The subscriber type this source opens.
Source§

fn name(&self) -> &str

The name (subject / channel) this subscription binds to. Read more
Source§

async fn subscribe( self, broker: &RedisTestBroker, ) -> Result<Self::Subscriber, RedisError>

Opens the subscription against broker. Called once, after Broker::connect. Read more
Source§

impl SubscriptionSource<RedisTestBroker> for RedisStream

Available on crate feature testing only.
Source§

type Subscriber = RedisTestSubscriber

The subscriber type this source opens.
Source§

fn name(&self) -> &str

The name (subject / channel) this subscription binds to. Read more
Source§

async fn subscribe( self, broker: &RedisTestBroker, ) -> Result<Self::Subscriber, RedisError>

Opens the subscription against broker. Called once, after Broker::connect. Read more
Source§

impl TestableBroker for RedisTestBroker

Source§

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<'_>)

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>

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§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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