pub trait RedisSubscribeExt {
// Required method
fn block(self, block: Duration) -> Self;
}Expand description
The Redis subscription options a mount site names, chained after the core’s settings steps.
Import it (or glob a form’s prelude) to reach block on a builder over a
RedisStream or a RedisList, with or without the window .pipeline() opens. The trait
is bound to those sources, so the method does not appear on a builder for another broker or
for a form that has no blocking read.
§Examples
use std::time::Duration;
use ruststream_fred::stream::prelude::*;
#[subscriber(RedisStream::new("orders").group("workers"))]
async fn bill(orders: &[Order]) -> HandlerOutcome {
let total: u64 = orders.iter().map(|order| order.amount).sum();
println!("billed {} orders, {total} in all", orders.len());
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("billing", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
// The size is the core's word, the block is Redis's, and they read in that order.
b.include(bill.batch(nonzero!(6)).block(Duration::from_secs(5)));
},
)
}Required Methods§
Sourcefn block(self, block: Duration) -> Self
fn block(self, block: Duration) -> Self
How long one read blocks waiting for entries, overriding what the descriptor named.
On a stream this is the XREADGROUP server-side BLOCK (and, in reclaim mode, the poll
interval between empty XAUTOCLAIM scans); on a list it is the BRPOP / BLMOVE timeout.
Both default to five seconds.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<Def, Mode, State, DefCodec> RedisSubscribeExt for SubscriberBuilder<Def, Pipelined<RedisList, Mode>, State, DefCodec>where
Def: Declared,
The same option on a list whose window .pipeline() has opened.
impl<Def, Mode, State, DefCodec> RedisSubscribeExt for SubscriberBuilder<Def, Pipelined<RedisList, Mode>, State, DefCodec>where
Def: Declared,
The same option on a list whose window .pipeline() has opened.
Source§impl<Def, Mode, State, DefCodec> RedisSubscribeExt for SubscriberBuilder<Def, Pipelined<RedisStream, Mode>, State, DefCodec>where
Def: Declared,
The same option on a stream whose window .pipeline() has opened, so the base settings read
in either order around it.
impl<Def, Mode, State, DefCodec> RedisSubscribeExt for SubscriberBuilder<Def, Pipelined<RedisStream, Mode>, State, DefCodec>where
Def: Declared,
The same option on a stream whose window .pipeline() has opened, so the base settings read
in either order around it.