pub struct RedisSentinelBuilder { /* private fields */ }Expand description
Builder for a Redis Sentinel topology.
§Example
use redis_server_wrapper::RedisSentinel;
let sentinel = RedisSentinel::builder()
.master_name("mymaster")
.master_port(6390)
.replicas(2)
.sentinels(3)
.start()
.await
.unwrap();
assert!(sentinel.is_healthy().await);Implementations§
Source§impl RedisSentinelBuilder
impl RedisSentinelBuilder
Sourcepub fn master_name(self, name: impl Into<String>) -> Self
pub fn master_name(self, name: impl Into<String>) -> Self
Set the name of the monitored master (default: "mymaster").
Sourcepub fn master_port(self, port: u16) -> Self
pub fn master_port(self, port: u16) -> Self
Set the master’s port (default: 6390).
Sourcepub fn replica_base_port(self, port: u16) -> Self
pub fn replica_base_port(self, port: u16) -> Self
Set the base port for replica nodes (default: 6391).
Replicas are assigned consecutive ports starting at this value.
Sourcepub fn sentinels(self, n: u16) -> Self
pub fn sentinels(self, n: u16) -> Self
Set the number of sentinel processes to start (default: 3).
Sourcepub fn sentinel_base_port(self, port: u16) -> Self
pub fn sentinel_base_port(self, port: u16) -> Self
Set the base port for sentinel processes (default: 26389).
Sentinels are assigned consecutive ports starting at this value.
Sourcepub fn quorum(self, q: u16) -> Self
pub fn quorum(self, q: u16) -> Self
Set the quorum count — how many sentinels must agree before a failover is triggered (default: 2).
Sourcepub fn bind(self, bind: impl Into<String>) -> Self
pub fn bind(self, bind: impl Into<String>) -> Self
Set the bind address for all processes in the topology (default: "127.0.0.1").
Sourcepub fn logfile(self, path: impl Into<String>) -> Self
pub fn logfile(self, path: impl Into<String>) -> Self
Set the log file path for all processes in the topology.
Sourcepub fn down_after_ms(self, ms: u64) -> Self
pub fn down_after_ms(self, ms: u64) -> Self
Set the down-after-milliseconds threshold for all monitored masters (default: 5000).
A master is considered down after it fails to respond within this many milliseconds.
Sourcepub fn failover_timeout_ms(self, ms: u64) -> Self
pub fn failover_timeout_ms(self, ms: u64) -> Self
Set the failover-timeout for all monitored masters in milliseconds (default: 10000).
Sourcepub fn save(self, save: bool) -> Self
pub fn save(self, save: bool) -> Self
Set the RDB save policy for all data-bearing processes in the topology.
true omits the save directive (Redis defaults apply).
false emits save "" to disable RDB entirely.
Sourcepub fn save_schedule(self, schedule: Vec<(u64, u64)>) -> Self
pub fn save_schedule(self, schedule: Vec<(u64, u64)>) -> Self
Set a custom RDB save schedule for all data-bearing processes in the topology.
Sourcepub fn appendonly(self, appendonly: bool) -> Self
pub fn appendonly(self, appendonly: bool) -> Self
Enable or disable AOF persistence for all data-bearing processes in the topology.
When not set, the builder defaults to appendonly yes for the master
and replicas.
Sourcepub fn tls_port(self, port: u16) -> Self
pub fn tls_port(self, port: u16) -> Self
Set the TLS listening port for the master and replica nodes.
Sourcepub fn tls_cert_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_cert_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS certificate file path for all nodes.
Sourcepub fn tls_key_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_key_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS private key file path for all nodes.
Sourcepub fn tls_ca_cert_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_ca_cert_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS CA certificate file path for all nodes.
Sourcepub fn tls_ca_cert_dir(self, path: impl Into<PathBuf>) -> Self
pub fn tls_ca_cert_dir(self, path: impl Into<PathBuf>) -> Self
Set the TLS CA certificate directory for all nodes.
Sourcepub fn tls_auth_clients(self, auth: bool) -> Self
pub fn tls_auth_clients(self, auth: bool) -> Self
Require TLS client authentication for all nodes.
Sourcepub fn tls_replication(self, enable: bool) -> Self
pub fn tls_replication(self, enable: bool) -> Self
Use TLS for replication traffic between nodes.
Sourcepub fn extra(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn extra(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set an arbitrary config directive for all processes in the topology.
Sourcepub fn redis_server_bin(self, bin: impl Into<String>) -> Self
pub fn redis_server_bin(self, bin: impl Into<String>) -> Self
Set a custom redis-server binary path.
Sourcepub fn redis_cli_bin(self, bin: impl Into<String>) -> Self
pub fn redis_cli_bin(self, bin: impl Into<String>) -> Self
Set a custom redis-cli binary path.
Sourcepub fn monitor(
self,
name: impl Into<String>,
host: impl Into<String>,
port: u16,
) -> Self
pub fn monitor( self, name: impl Into<String>, host: impl Into<String>, port: u16, ) -> Self
Add an additional master for the sentinels to monitor.
The builder-managed topology still creates the primary master configured by
Self::master_name and Self::master_port. Additional monitored
masters are expected to already be running.
Sourcepub fn monitor_with_replicas(
self,
name: impl Into<String>,
host: impl Into<String>,
port: u16,
expected_replicas: u16,
) -> Self
pub fn monitor_with_replicas( self, name: impl Into<String>, host: impl Into<String>, port: u16, expected_replicas: u16, ) -> Self
Add an additional master and the minimum number of replicas expected for it.
Sourcepub async fn start(self) -> Result<RedisSentinelHandle>
pub async fn start(self) -> Result<RedisSentinelHandle>
Start the full topology: master, replicas, sentinels.
Auto Trait Implementations§
impl Freeze for RedisSentinelBuilder
impl RefUnwindSafe for RedisSentinelBuilder
impl Send for RedisSentinelBuilder
impl Sync for RedisSentinelBuilder
impl Unpin for RedisSentinelBuilder
impl UnsafeUnpin for RedisSentinelBuilder
impl UnwindSafe for RedisSentinelBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more