1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! A Redis Streams service: one `#[subscriber]` handler bound to a stream key, wired onto a
//! [`RedisBroker`].
//!
//! `RedisBroker::standalone` is synchronous and does no I/O, so the whole service fits the
//! `#[ruststream::app]` macro just like the in-memory examples. The runtime connects the broker once
//! at startup (`Broker::connect`) before opening subscriptions, and the generated binary understands
//! `run` and `asyncapi gen`.
//!
//! Redis Streams always read through a consumer group, so the bare-string subscriber form needs a
//! broker-wide default group (`.default_group`). For per-subscription control (fresh tail vs
//! reclaim, count, block) use the [`RedisStream`](ruststream_fred::RedisStream) descriptor instead.
//!
//! Start a Redis server first (`docker run -p 6379:6379 redis:7`), then:
//!
//! ```text
//! cargo run --example fred_streams --features macros,json -- run
//! ```
//!
//! Publish an order from another terminal with the Redis CLI:
//!
//! ```text
//! redis-cli XADD orders '*' _payload '{"id":1}'
//! ```
// --8<-- [start:handler]
use ;
use subscriber;
use RedisBroker;
use Deserialize;
async
// --8<-- [end:handler]
// --8<-- [start:app]
// --8<-- [end:app]