GenServer managing a Redis Sentinel topology: master + replicas + sentinel processes.
Usage
{:ok, pid} = RedisServerWrapper.Sentinel.start_link(
master_port: 6390,
replicas: 2,
sentinels: 3
)
RedisServerWrapper.Sentinel.healthy?(pid)
RedisServerWrapper.Sentinel.master_addr(pid)
RedisServerWrapper.Sentinel.stop(pid)Options
:master_name- sentinel master name (default: "mymaster"):master_port- master port (default: 6390):replicas- number of replica nodes (default: 2):replica_base_port- starting port for replicas (default: master_port + 1):sentinels- number of sentinel processes (default: 3):sentinel_base_port- starting port for sentinels (default: 26389):quorum- sentinel quorum (default: 2):down_after_ms- down-after-milliseconds (default: 5000):failover_timeout_ms- failover timeout (default: 10_000):bind- bind address (default: "127.0.0.1"):control_host- address used by redis-cli, replication, and Sentinel monitoring (default: first bind address):password- Redis password:username- optional ACL username paired with:password:tls- use TLS-only data-node and Sentinel connections (default: false):tls_cert_file,:tls_key_file- server certificate and private key:tls_ca_cert_fileor:tls_ca_cert_dir- trusted CA for Redis and redis-cli:tls_client_cert_file,:tls_client_key_file- optional redis-cli client identity:tls_server_name- optional redis-cli SNI name:tls_insecure- explicitly disable redis-cli certificate verification:redis_server_bin- redis-server binary path:redis_cli_bin- redis-cli binary path:distribution-:core(default),:full, or:legacy_stack:timeout- startup timeout per node in ms (default: 10_000):convergence_timeout- bounded wait for replication and Sentinel discovery (default: the value of:timeout):loadmodule- modules loaded into the master and every replica; accepts paths or{path, [args]}tuples (default:[]). Sentinel processes do not load data modules.:managed- process lifecycle backend forwarded to the master and every replica. SeeRedisServerWrapper.Serverfortrue,:forcola, andfalse. Sentinel control processes use the same selected backend. Onlymanaged: falsesupportsdetach/1.
Summary
Functions
Returns a specification to start this module under a supervisor.
Detaches daemonized data nodes so their OS processes survive this GenServer.
Checks sentinel health: master reachable, expected replicas and sentinels.
Returns info about the topology.
Returns the master address.
Queries SENTINEL MASTER for the given master name.
Returns all sentinel addresses.
Stops the sentinel topology.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec detach(GenServer.server()) :: :ok | {:error, :managed_server}
Detaches daemonized data nodes so their OS processes survive this GenServer.
@spec healthy?(GenServer.server()) :: boolean()
Checks sentinel health: master reachable, expected replicas and sentinels.
@spec info(GenServer.server()) :: map()
Returns info about the topology.
@spec master_addr(GenServer.server()) :: String.t()
Returns the master address.
@spec poke(GenServer.server()) :: {:ok, map()} | {:error, term()}
Queries SENTINEL MASTER for the given master name.
@spec sentinel_addrs(GenServer.server()) :: [String.t()]
Returns all sentinel addresses.
@spec start(keyword()) :: GenServer.on_start()
@spec start_link(keyword()) :: GenServer.on_start()
@spec stop(GenServer.server()) :: :ok
Stops the sentinel topology.