Skip to main content

Sentinel

RedisBroker::sentinel names the monitored primary and the sentinels that watch it; the client finds the primary through them.

The first argument is the name the sentinels monitor the primary under, such as mymaster. The second is the sentinels, each a host:port address; a sentinel without a port means 26379. At startup the client asks the sentinels where the primary is and connects to it. Every read and every write goes to the primary.

After a failover the connections reconnect, and the client asks the sentinels again, so the service follows the new primary. A sentinel list carries no password. The primary's password goes in credentials, and the sentinels' own in sentinel_credentials.

Example​

The service reaches the primary mymaster through either of two sentinels.

/// The primary `mymaster`, found through either of two sentinels.
fn broker() -> RedisBroker {
RedisBroker::sentinel(
"mymaster",
["sentinel-1.internal:26379", "sentinel-2.internal:26379"],
)
}

#[ruststream::app]
fn app() -> impl App<State = ()> {
service(broker())
}