跳到主要内容
本页尚未翻译

下面显示的是英文原文。

sentinel_credentials

sentinel_credentials and sentinel_password log in to the sentinels with a pair of their own, apart from the data nodes.

A Sentinel deployment may protect the sentinels and the primary separately. The client asks the sentinels where the primary is, logged in with sentinel_credentials, and then logs in to the primary with credentials. sentinel_password is the form with a password and no user. Both come with the sentinel-auth feature and apply to the sentinel topology only.

A TestApp test runs no handshake, so it proves the service starts and works with both pairs set.

Example​

The dependency line:

ruststream-fred = { version = "0.7", features = ["sentinel-auth"] }

The primary checks the user worker, and the sentinels the user monitor.

/// The data nodes check the user `worker`, the sentinels the user `monitor`.
fn broker(data_password: &str, sentinel_password: &str) -> RedisBroker {
RedisBroker::sentinel(
"mymaster",
["sentinel-1.internal:26379", "sentinel-2.internal:26379"],
)
.credentials("worker", data_password)
.sentinel_credentials("monitor", sentinel_password)
}

#[ruststream::app]
fn app() -> impl App<State = ()> {
let data_password = env::var("REDIS_PASSWORD").unwrap_or_default();
let sentinel_password = env::var("SENTINEL_PASSWORD").unwrap_or_default();
service(broker(&data_password, &sentinel_password))
}