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 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