Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 96f2172

Browse files
committed
Make option argument in cluster_failover optional argument
1 parent 95fee79 commit 96f2172

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rediscluster/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,19 @@ def cluster_delslots(self, *slots):
804804
for slot in slots
805805
]
806806

807-
def cluster_failover(self, node_id, option):
807+
def cluster_failover(self, node_id, option=None):
808808
"""
809809
Forces a slave to perform a manual failover of its master
810810
811811
Sends to specefied node
812812
"""
813-
assert option.upper() in ('FORCE', 'TAKEOVER') # TODO: change this option handling
814-
return self.execute_command('CLUSTER FAILOVER', option, node_id=node_id)
813+
if option:
814+
if option.upper() not in ['FORCE', 'TAKEOVER']:
815+
raise RedisError('Invalid option for CLUSTER FAILOVER command: {0}'.format(option))
816+
else:
817+
return self.execute_command('CLUSTER FAILOVER', option, node_id=node_id)
818+
else:
819+
return self.execute_command('CLUSTER FAILOVER', node_id=node_id)
815820

816821
def cluster_info(self):
817822
"""

0 commit comments

Comments
 (0)