Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def hijack_multiple_action(db_con, connection, hijack_keys, action):
correlation_id = uuid()
callback_queue = Queue(
uuid(),
channel=connection.default_channel,
durable=False,
exclusive=True,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
with connection.Producer() as producer:
producer.publish(
{"keys": hijack_keys, "action": action},
exchange="",
routing_key="db-hijack-multiple-action",
retry=True,
declare=[callback_queue],
reply_to=callback_queue.name,
correlation_id=correlation_id,
def load_as_sets(connection):
correlation_id = uuid()
callback_queue = Queue(
uuid(),
channel=connection.default_channel,
durable=False,
exclusive=True,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
with connection.Producer() as producer:
producer.publish(
{},
exchange="",
routing_key="conf-load-as-sets-queue",
retry=True,
declare=[callback_queue],
def config_request_rpc(conn):
"""
Initial RPC of this service to request the configuration.
The RPC is blocked until the configuration service replies back.
"""
correlation_id = uuid()
callback_queue = Queue(
uuid(),
channel=conn.default_channel,
durable=False,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
with conn.Producer() as producer:
producer.publish(
"",
exchange="",
routing_key="config-request-queue",
reply_to=callback_queue.name,
correlation_id=correlation_id,
def change_conf(connection, new_config, old_config, comment):
changes = "".join(difflib.unified_diff(new_config, old_config))
if changes:
correlation_id = uuid()
callback_queue = Queue(
uuid(),
channel=connection.default_channel,
durable=False,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
with connection.Producer() as producer:
producer.publish(
{"config": new_config, "comment": comment},
exchange="",
routing_key="config-modify-queue",
serializer="yaml",
retry=True,
declare=[callback_queue],
reply_to=callback_queue.name,
correlation_id=correlation_id,
def config_request_rpc(self):
self.correlation_id = uuid()
callback_queue = Queue(uuid(), durable=False, max_priority=2,
consumer_arguments={'x-priority': 2})
self.producer.publish(
'',
exchange = '',
routing_key = 'config_request_queue',
reply_to = callback_queue.name,
correlation_id = self.correlation_id,
retry = True,
declare = [callback_queue, Queue('config_request_queue', durable=False, max_priority=2)],
priority = 2
)
with Consumer(self.connection,
on_message=self.handle_config_request_reply,
queues=[callback_queue], no_ack=True):
durable=False,
auto_delete=True,
max_priority=2,
consumer_arguments={"x-priority": 2},
)
self.hijack_ongoing_queue = Queue(
"detection-hijack-ongoing",
exchange=self.hijack_exchange,
routing_key="ongoing",
durable=False,
auto_delete=True,
max_priority=1,
consumer_arguments={"x-priority": 1},
)
self.config_queue = Queue(
"detection-config-notify-{}".format(uuid()),
exchange=self.config_exchange,
routing_key="notify",
durable=False,
auto_delete=True,
max_priority=3,
consumer_arguments={"x-priority": 3},
)
self.update_rekey_queue = Queue(
"detection-update-rekey",
exchange=self.update_exchange,
routing_key="hijack-rekey",
durable=False,
auto_delete=True,
max_priority=1,
consumer_arguments={"x-priority": 1},
)
def config_request_rpc(self) -> NoReturn:
"""
Initial RPC of this service to request the configuration.
The RPC is blocked until the configuration service replies back.
"""
self.correlation_id = uuid()
callback_queue = Queue(
uuid(),
durable=False,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
self.producer.publish(
"",
exchange="",
routing_key="config-request-queue",
reply_to=callback_queue.name,
correlation_id=self.correlation_id,
retry=True,
declare=[
Queue(
"config-request-queue",
def __init__(self, connection):
self.connection = connection
self.flag = False
self.time_to_wait = 1 # Time in secs to gather entries to perform a bulk operation
self.time_to_wait_to_send_unhadled = 5
self.db_clock_exchange = Exchange('db_clock', type='direct', durable=False, delivery_mode=1)
self.db_clock_queue = Queue(uuid(), exchange=self.db_clock_exchange, routing_key='db_clock', durable=False, exclusive=True, max_priority=2,
consumer_arguments={'x-priority': 3})
self.flag = True
log.info('Scheduler Started..')
self.db_clock_send()
def config_request_rpc(self) -> NoReturn:
"""
Initial RPC of this service to request the configuration.
The RPC is blocked until the configuration service replies back.
"""
self.correlation_id = uuid()
callback_queue = Queue(
uuid(),
durable=False,
auto_delete=True,
max_priority=4,
consumer_arguments={"x-priority": 4},
)
self.producer.publish(
"",
exchange="",
routing_key="config-request-queue",
reply_to=callback_queue.name,
correlation_id=self.correlation_id,
retry=True,
declare=[