diff options
author | Bar Shaul <88437685+barshaul@users.noreply.github.com> | 2021-12-02 22:59:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 22:59:06 +0200 |
commit | 11b14630a6845c28acfd4220b72ed62d72913305 (patch) | |
tree | 7c4ae49db2320416a956551613d90cad26b44052 /redis/cluster.py | |
parent | b7ffec08da97b71b10bbd139b32ff82d33d907f1 (diff) | |
download | redis-py-11b14630a6845c28acfd4220b72ed62d72913305.tar.gz |
Added support for MONITOR in clusters (#1756)
Diffstat (limited to 'redis/cluster.py')
-rw-r--r-- | redis/cluster.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/redis/cluster.py b/redis/cluster.py index c5634a0..b1adeb7 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -670,6 +670,23 @@ class RedisCluster(RedisClusterCommands): log.info(f"Changed the default cluster node to {node}") return True + def monitor(self, target_node=None): + """ + Returns a Monitor object for the specified target node. + The default cluster node will be selected if no target node was + specified. + Monitor is useful for handling the MONITOR command to the redis server. + next_command() method returns one command from monitor + listen() method yields commands from monitor. + """ + if target_node is None: + target_node = self.get_default_node() + if target_node.redis_connection is None: + raise RedisClusterException( + f"Cluster Node {target_node.name} has no redis_connection" + ) + return target_node.redis_connection.monitor() + def pubsub(self, node=None, host=None, port=None, **kwargs): """ Allows passing a ClusterNode, or host&port, to get a pubsub instance |