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"):password- Redis password:redis_server_bin- redis-server binary path:redis_cli_bin- redis-cli binary path:timeout- startup timeout per node in ms (default: 10_000):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. Onlymanaged: falsesupportsdetach/1. Sentinel processes always daemonize regardless of this flag.
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.