Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def monitor(self, name, ip, port, quorum):
"""Add a new master to Sentinel to be monitored."""
fut = self.execute(b'MONITOR', name, ip, port, quorum)
return wait_ok(fut)
raise TypeError("expire argument must be int")
if pexpire and not isinstance(pexpire, int):
raise TypeError("pexpire argument must be int")
args = []
if expire:
args[:] = [b'EX', expire]
if pexpire:
args[:] = [b'PX', pexpire]
if exist is self.SET_IF_EXIST:
args.append(b'XX')
elif exist is self.SET_IF_NOT_EXIST:
args.append(b'NX')
fut = self.execute(b'SET', key, value, *args)
return wait_ok(fut)
def xgroup_setid(self, stream, group_name, latest_id='$'):
"""Set the latest ID for a consumer group"""
fut = self.execute(b'XGROUP', b'SETID', stream, group_name, latest_id)
return wait_ok(fut)
def pfmerge(self, destkey, sourcekey, *sourcekeys):
"""Merge N different HyperLogLogs into a single one."""
fut = self.execute(b'PFMERGE', destkey, sourcekey, *sourcekeys)
return wait_ok(fut)
def script_kill(self):
"""Kill the script currently in execution."""
fut = self.execute(b'SCRIPT', b'KILL')
return wait_ok(fut)
def bgrewriteaof(self):
"""Asynchronously rewrite the append-only file."""
fut = self.execute(b'BGREWRITEAOF')
return wait_ok(fut)
def rename(self, key, newkey):
"""Renames key to newkey.
:raises ValueError: if key == newkey
"""
if key == newkey:
raise ValueError("key and newkey are the same")
fut = self.execute(b'RENAME', key, newkey)
return wait_ok(fut)
def client_pause(self, timeout):
"""Stop processing commands from clients for *timeout* milliseconds.
:raises TypeError: if timeout is not int
:raises ValueError: if timeout is less than 0
"""
if not isinstance(timeout, int):
raise TypeError("timeout argument must be int")
if timeout < 0:
raise ValueError("timeout must be greater equal 0")
fut = self.execute(b'CLIENT', b'PAUSE', timeout)
return wait_ok(fut)
def cluster_forget(self, node_id):
"""Remove a node from the nodes table."""
fut = self.execute(b'CLUSTER', b'FORGET', node_id)
return wait_ok(fut)
def cluster_add_slots(self, slot, *slots):
"""Assign new hash slots to receiving node."""
slots = (slot,) + slots
if not all(isinstance(s, int) for s in slots):
raise TypeError("All parameters must be of type int")
fut = self.execute(b'CLUSTER', b'ADDSLOTS', *slots)
return wait_ok(fut)