Skip to content

Redis broker

ruststream-fred is the Redis broker for the RustStream framework. It is built on Redis Streams: every subscription reads through a consumer group, so deliveries are durable and acknowledged. It also ships an in-memory test broker under its testing feature.

ruststream = { version = "0.6", features = ["macros"] }
ruststream-fred = "0.6"
serde = { version = "1", features = ["derive"] }

RedisBroker::standalone is synchronous and does no I/O, so a Redis service is assembled with the same #[ruststream::app] macro as any other broker. The runtime drives the lifecycle ladder at startup: the consuming connect produces the ConnectedRedisBroker that subscriptions and publishers hang off, and the consuming shutdown closes it. Publishers are declared as a policy (RedisPublish, RedisPubSubPublish, RedisListPublish) that the runtime pairs with the connected broker, so publishing before connect cannot be expressed.

Scaffold a service

Generate a runnable starter with cargo generate, one template per transport:

cargo generate --git https://github.com/powersemmi/ruststream-fred templates/redis-stream
cargo generate --git https://github.com/powersemmi/ruststream-fred templates/redis-pubsub
cargo generate --git https://github.com/powersemmi/ruststream-fred templates/redis-list

Topologies

One crate, three named constructors. Each is synchronous and I/O-free; the connection opens in connect:

# standalone
# RedisBroker::standalone("redis://localhost:6379")
# cluster (one reachable seed node is enough; the rest is discovered)
# RedisBroker::cluster(["127.0.0.1:7000", "127.0.0.1:7001"])
# sentinel (the monitored primary's name plus the sentinels)
# RedisBroker::sentinel("mymaster", ["127.0.0.1:26379"])

Transport guides