diff options
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 |