pub struct RedisSentinelTemplate { /* private fields */ }Expand description
Redis Sentinel template for high availability setup
Implementations§
Source§impl RedisSentinelTemplate
impl RedisSentinelTemplate
Sourcepub fn master_name(self, name: impl Into<String>) -> Self
pub fn master_name(self, name: impl Into<String>) -> Self
Set the master name for Sentinel monitoring
Sourcepub fn num_replicas(self, num: usize) -> Self
pub fn num_replicas(self, num: usize) -> Self
Set the number of Redis replicas
Sourcepub fn num_sentinels(self, num: usize) -> Self
pub fn num_sentinels(self, num: usize) -> Self
Set the number of Sentinel instances
Sourcepub fn master_port(self, port: u16) -> Self
pub fn master_port(self, port: u16) -> Self
Set the Redis master port
Sourcepub fn replica_port_base(self, port: u16) -> Self
pub fn replica_port_base(self, port: u16) -> Self
Set the base port for replicas (will increment for each replica)
Sourcepub fn sentinel_port_base(self, port: u16) -> Self
pub fn sentinel_port_base(self, port: u16) -> Self
Set the base port for Sentinels (will increment for each Sentinel)
Sourcepub fn password(self, password: impl Into<String>) -> Self
pub fn password(self, password: impl Into<String>) -> Self
Set Redis password for authentication
Sourcepub fn down_after_milliseconds(self, ms: u32) -> Self
pub fn down_after_milliseconds(self, ms: u32) -> Self
Set the time in milliseconds before master is considered down
Sourcepub fn failover_timeout(self, ms: u32) -> Self
pub fn failover_timeout(self, ms: u32) -> Self
Set the failover timeout in milliseconds
Sourcepub fn parallel_syncs(self, num: u32) -> Self
pub fn parallel_syncs(self, num: u32) -> Self
Set the number of parallel syncs during failover
Sourcepub fn with_persistence(self) -> Self
pub fn with_persistence(self) -> Self
Enable persistence for Redis instances
Sourcepub fn announce_ip(self, ip: impl Into<String>) -> Self
pub fn announce_ip(self, ip: impl Into<String>) -> Self
Set the IP address to announce to Sentinel-aware clients.
By default Sentinel monitors the master by its container hostname and reports replica/sentinel addresses using internal Docker addresses, which are unreachable from a host-side client. Setting an announce IP makes the topology reachable from outside the Docker network:
- the monitored master is registered at
<announce_ip>:<master_port>, soSENTINEL get-master-addr-by-namereturns a host-reachable address, - each replica announces
<announce_ip>:<replica_host_port>, - each sentinel announces
<announce_ip>:<sentinel_host_port>.
Use 127.0.0.1 (or the host’s LAN address) when connecting from the
machine running Docker.
Sourcepub fn custom_redis_image(
self,
image: impl Into<String>,
tag: impl Into<String>,
) -> Self
pub fn custom_redis_image( self, image: impl Into<String>, tag: impl Into<String>, ) -> Self
Use a custom Redis image and tag