Skip to main content

RedisPubSubAtomic

Type Alias RedisPubSubAtomic 

Source
pub type RedisPubSubAtomic = Pipelined<RedisPubSub, Atomic>;
Expand description

A Pub/Sub channel subscription with an atomic window: what .pipeline().atomic() at the mount site makes of a RedisPubSub.

§Examples

use ruststream_fred::pubsub::prelude::*;

#[subscriber(RedisPubSub::new("events"))]
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 `RedisPubSubAtomic`.
            b.include(record.pipeline().atomic());
        },
    )
}

Aliased Type§

pub struct RedisPubSubAtomic { /* private fields */ }