Skip to main content

RedisStreamAtomic

Type Alias RedisStreamAtomic 

Source
pub type RedisStreamAtomic = Pipelined<RedisStream, Atomic>;
Expand description

A stream subscription with an atomic window: what .pipeline().atomic() at the mount site makes of a RedisStream.

§Examples

use ruststream_fred::stream::prelude::*;

#[subscriber(RedisStream::new("{orders}").group("workers"))]
async fn record(event: &Event, Ctx(pipeline): Ctx<keys::Pipeline>) -> HandlerOutcome {
    if pipeline.incr(format!("seen:{}", event.id)).await.is_err() {
        return HandlerOutcome::retry();
    }
    HandlerOutcome::ack()
}

fn app() -> RustStream {
    RustStream::new(AppInfo::new("events", "0.1.0")).with_broker(
        RedisBroker::standalone("redis://localhost:6379"),
        |b| {
            // The source of this registration is a `RedisStreamAtomic`.
            b.include(record.pipeline().atomic());
        },
    )
}

Aliased Type§

pub struct RedisStreamAtomic { /* private fields */ }