Commit 9e9c7065 authored by Alexander Lercher's avatar Alexander Lercher

Extracted network constants

parent 72cf9efd
import pika import pika
import functools import functools
from threading import Thread from threading import Thread
import network_constants as netconst
import logging import logging
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -18,7 +19,7 @@ class MessageReceiver: ...@@ -18,7 +19,7 @@ class MessageReceiver:
_message_received_callback = None _message_received_callback = None
_error_callback = None _error_callback = None
def __init__(self, exchange_name='beacon', exchange_type='fanout', rabbit_mq_ip='143.205.173.36', rabbit_mq_port=30302, queue_name='', auto_ack=True): def __init__(self, exchange_name='beacon', exchange_type='fanout', rabbit_mq_ip=netconst.RABBIT_MQ_HOSTNAME, rabbit_mq_port=netconst.RABBIT_MQ_PORT, queue_name='', auto_ack=True):
self._exchange_name = exchange_name self._exchange_name = exchange_name
self._exchange_type = exchange_type self._exchange_type = exchange_type
self._rabbit_mq_ip = rabbit_mq_ip self._rabbit_mq_ip = rabbit_mq_ip
......
import pika import pika
import functools import functools
from threading import Thread from threading import Thread
import network_constants as netconst
import logging import logging
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -13,7 +14,7 @@ class MessageSender: ...@@ -13,7 +14,7 @@ class MessageSender:
_connection: pika.BlockingConnection = None _connection: pika.BlockingConnection = None
_channel: pika.channel.Channel = None _channel: pika.channel.Channel = None
def __init__(self, rabbit_mq_ip='rabbit-mq', rabbit_mq_port=5672): def __init__(self, rabbit_mq_ip=netconst.RABBIT_MQ_HOSTNAME, rabbit_mq_port=netconst.RABBIT_MQ_PORT):
self._rabbit_mq_ip = rabbit_mq_ip self._rabbit_mq_ip = rabbit_mq_ip
self._rabbit_mq_port = rabbit_mq_port self._rabbit_mq_port = rabbit_mq_port
......
### inside k8s
RABBIT_MQ_HOSTNAME = 'rabbit-mq'
RABBIT_MQ_PORT = 5672
MONGO_DB_HOST = 'trace-retrieval-db'
MONGO_DB_PORT = 27017
### outside k8s
# HOST_IP = '143.205.173.36'
# RABBIT_MQ_HOSTNAME = HOST_IP
# RABBIT_MQ_PORT = 30302
# MONGO_DB_HOST = HOST_IP
# MONGO_DB_PORT = 30003
\ No newline at end of file
import pymongo import pymongo
import network_constants as netconst
MONGO_DB_HOST = 'trace-retrieval-db'
MONGO_DB_PORT = '27017'
class MongoRepository: class MongoRepository:
# TODO extract to docker env var # TODO extract to docker env var
...@@ -12,7 +10,7 @@ class MongoRepository: ...@@ -12,7 +10,7 @@ class MongoRepository:
_mongo_client: pymongo.MongoClient = None _mongo_client: pymongo.MongoClient = None
def __init__(self, username=_username, password=_password): def __init__(self, username=_username, password=_password):
self._mongo_client = pymongo.MongoClient(f"mongodb://{username}:{password}@{MONGO_DB_HOST}:{MONGO_DB_PORT}/") self._mongo_client = pymongo.MongoClient(f"mongodb://{username}:{password}@{netconst.MONGO_DB_HOST}:{netconst.MONGO_DB_PORT}/")
database = self._mongo_client['traceRetrievalDB'] database = self._mongo_client['traceRetrievalDB']
self._collection = database['traces'] self._collection = database['traces']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment