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, before or after the window .pipeline() opens and the
position start_at(..) names. 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();
tracing::info!(orders = orders.len(), total, "billed");
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".