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
impl RedisTestBroker
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a fresh, isolated test broker. Equivalent to Self::default.
Sourcepub async fn subscribe(
&self,
key: impl Into<String>,
) -> Result<RedisTestSubscriber, RedisError>
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.
Sourcepub fn publisher(&self) -> RedisTestPublisher
pub fn publisher(&self) -> RedisTestPublisher
Returns a publisher bound to this broker. Cheap to clone.
Sourcepub async fn expect_published(
&self,
key: &str,
count: usize,
timeout_dur: Duration,
) -> Vec<RawMessage>
pub async fn expect_published( &self, key: &str, count: usize, timeout_dur: Duration, ) -> Vec<RawMessage>
Awaits until count messages have landed on key (or the timeout elapses) and returns the
recorded prefix of the published log. Returns whatever is recorded on timeout, never
blocking past it.
Trait Implementations§
Source§impl Broker for RedisTestBroker
impl Broker for RedisTestBroker
Source§impl Clone for RedisTestBroker
impl Clone for RedisTestBroker
Source§fn clone(&self) -> RedisTestBroker
fn clone(&self) -> RedisTestBroker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedisTestBroker
impl Debug for RedisTestBroker
Source§impl Default for RedisTestBroker
impl Default for RedisTestBroker
Source§fn default() -> RedisTestBroker
fn default() -> RedisTestBroker
Source§impl DescribeServer for RedisTestBroker
impl DescribeServer for RedisTestBroker
Source§fn describe_server(&self) -> ServerSpec
fn describe_server(&self) -> ServerSpec
Source§impl Subscribe for RedisTestBroker
impl Subscribe for RedisTestBroker
Source§type Subscriber = RedisTestSubscriber
type Subscriber = RedisTestSubscriber
Auto Trait Implementations§
impl Freeze for RedisTestBroker
impl RefUnwindSafe for RedisTestBroker
impl Send for RedisTestBroker
impl Sync for RedisTestBroker
impl Unpin for RedisTestBroker
impl UnsafeUnpin for RedisTestBroker
impl UnwindSafe for RedisTestBroker
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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