Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions redis/commands/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ class RedisClusterCommands(
r.cluster_info(target_nodes=RedisCluster.ALL_NODES)
"""

def cluster_myid(self, target_node):
"""
Returns the node’s id.

:target_node: 'ClusterNode'
The node to execute the command on

For more information check https://redis.io/commands/cluster-myid/
"""
return self.execute_command("CLUSTER MYID", target_nodes=target_node)

def cluster_addslots(self, target_node, *slots):
"""
Assign new hash slots to receiving node. Sends to specified node.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,11 @@ def test_cluster_pubsub_numsub(self, r):
channels = [(b"foo", 1), (b"bar", 2), (b"baz", 3)]
assert r.pubsub_numsub("foo", "bar", "baz", target_nodes="all") == channels

def test_cluster_myid(self, r):
node = r.get_random_node()
myid = r.cluster_myid(node)
assert len(myid) == 40

def test_cluster_slots(self, r):
mock_all_nodes_resp(r, default_cluster_slots)
cluster_slots = r.cluster_slots()
Expand Down