-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
While phpredis doesn't implement functionality to direct traffic using redis-sentinel, it can (and should) be possible to communicate with and execute commands against a sentinel.
I've implemented the SENTINEL
command in phpredis along will all of the current variants. This is a somewhat complicated command, as the SENTINEL
command itself takes a variety of argument types/combinations depending on the subcommand being executed.
That being said, we try to implement Redis commands in phpredis the way they are done in redis-server, and SENTINEL
is one command with a lot of subcommands and arguments
Proper documentation to follow, but the commands as implemented are as follows:
$redis->sentinel('masters');
$redis->sentinel('master', $master_name);
$redis->sentinel('slaves', $master_name);
$redis->sentinel('get-master-addr-by-name', $master_name);
$redis->sentinel('reset', $pattern);
$redis->sentinel('failover', $master_name);
$redis->sentinel('monitor', $master_name, $ip, $port, $quorum);
$redis->sentinel('remove', $master_name);
$redis->sentinel('set', $master_name, $option, $value);
Included in the commit I'll attach to this issue is a basic shell script to spin up a few redis-server instances as well as a sentinel to monitor them, and unit tests that can be run against it.
It would be great if we could get feedback on the implementation and as always please report any segfaults, memory corruption, or other nastiness.
Cheers,
Mike