Skip to main content

Module pubsub

Module pubsub 

Source
Expand description

Redis Pub/Sub transport: fire-and-forget fan-out with no acknowledgement.

Unlike Streams, Pub/Sub has no durability, no consumer groups, and no ack: a message reaches whichever subscribers are connected at publish time, and ack / nack report AckError::Unsupported. Two delivery modes exist, explicit because they do not interoperate:

  • PubSubMode::Classic - SUBSCRIBE / PUBLISH, broadcast to every node; supports patterns (PSUBSCRIBE). The only option on standalone and sentinel.
  • PubSubMode::Sharded - SSUBSCRIBE / SPUBLISH (Redis 7+), slot-local so it scales across a cluster, but has no pattern support.

A channel and a pattern are two descriptors, RedisPubSub and RedisPubSubPattern, because they differ in more than a flag: a pattern reads many channels and names none, so sharded delivery has no meaning there and neither does a destination a retry copy could go to.

Headers travel in a frame around the payload: a binary frame by default, or a readable codec-serialized envelope when a codec is set with RedisPubSub::codec / RedisPubSubPublish::codec. Both framings are lossless; the envelope writes a field whose bytes are valid UTF-8 as text and any other bytes as themselves.

Re-exports§

pub use crate::pubsub::RedisPubSubPublish as Publish;

Modules§

prelude
The core prelude plus everything a Redis Pub/Sub service writes.

Structs§

RedisPubSub
Describes one Pub/Sub subscription on a single channel, against a ConnectedRedisBroker.
RedisPubSubMessage
A Pub/Sub delivery. ack / nack are unsupported (Pub/Sub has no acknowledgement).
RedisPubSubPattern
Describes one Pub/Sub subscription on a glob pattern (PSUBSCRIBE), against a ConnectedRedisBroker.
RedisPubSubPublish
The declaration half of the Pub/Sub publisher: delivery mode and envelope codec, no connection.
RedisPubSubPublisher
Publishes Pub/Sub messages with PUBLISH (classic) or SPUBLISH (sharded): a RedisPubSubPublish policy paired with a connection.
RedisPubSubSubscriber
A Pub/Sub subscription backed by a dedicated fred client, so its message stream and channel state are isolated from other subscribers and from the publishing pool.

Enums§

PubSubMode
Pub/Sub delivery mode. Defaults to Classic.