Skip to content

Commit

Permalink
bc-1308 set content type and use exchange (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro authored Mar 7, 2022
1 parent 3200adf commit b91f6d4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion antivirus_service/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self, settings, handler):
self.handler = handler
self.amqp_config = settings.config[settings.env]['amqp']
self.amqp_url = self.amqp_config['url']
self.exchange = self.amqp_config['exchange']
self.amqp_queue = None

def _callback(self, ch, method, properties, body):
Expand All @@ -36,7 +37,8 @@ def run(self):

channel = self.connection.channel()
channel.queue_declare(self.amqp_queue)
channel.basic_consume(self.amqp_queue,self._callback)
channel.queue_bind(self.amqp_queue, self.exchange)
channel.basic_consume(self.amqp_queue, self._callback)
channel.start_consuming()

def stop(self):
Expand Down
2 changes: 1 addition & 1 deletion antivirus_service/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def scan(self, download_uri, access_token):

def callback(self, callback_uri, access_token, scan_result, signature):
logging.info('Start callback')
headers = {}
headers = {'Content-type': 'application/json'}
if access_token:
headers['Authorization'] = 'Bearer %s' % access_token

Expand Down
1 change: 1 addition & 0 deletions antivirus_service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, env, debug):
with env.prefixed(param.upper() + "_"):
self.config[self.env][param] = {}
self.config[self.env][param]['url'] = env("URL", "amqp://rabbitmq/antivirus")
self.config[self.env][param]['exchange'] = env("EXCHANGE", "antivirus")
with env.prefixed("SCAN_FILE_"):
self.config[self.env][param]['scan_file'] = {}
self.config[self.env][param]['scan_file']['queue'] = env("QUEUE", "scan_file")
Expand Down
2 changes: 1 addition & 1 deletion antivirus_service/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def send(self, body, routing_key):
params = pika.URLParameters(self.amqp_config['url'])
with pika.BlockingConnection(params) as con:
with con.channel() as channel:
channel.basic_publish(body=body, exchange='', routing_key=routing_key)
channel.basic_publish(body=body, exchange=self.amqp_config['exchange'], routing_key=routing_key)

@auth_required
async def handle_version(self, request):
Expand Down

0 comments on commit b91f6d4

Please sign in to comment.