diff --git a/tol_lab_share/config/defaults.py b/tol_lab_share/config/defaults.py index 2a685aa..01a373e 100644 --- a/tol_lab_share/config/defaults.py +++ b/tol_lab_share/config/defaults.py @@ -2,7 +2,7 @@ import os from tol_lab_share.config.logging import * -from tol_lab_share.config.rabbit import * +from .rabbit import * # If we're running in a container, then instead of localhost # we want host.docker.internal, you can specify this in the @@ -26,3 +26,11 @@ # Validate SSL certificate chain when connecting to https CERTIFICATES_VALIDATION_ENABLED = True + +RABBITMQ_PUBLISH_RETRY_DELAY = 5 +RABBITMQ_PUBLISH_RETRIES = 36 # 3 minutes of retries + +# In our servers, this will be picked up using deployment project's +# roles/deploy_tol_stack/templates/tol-lab-share/app_config.py.j2 and +# environments/uat/group_vars/tol_swarm_managers.yml +MLWH_ENVIRONMENT_NAME = os.environ.get("MLWH_ENVIRONMENT_NAME", "development") diff --git a/tol_lab_share/config/rabbit.py b/tol_lab_share/config/rabbit.py index 1be8451..3114bb2 100644 --- a/tol_lab_share/config/rabbit.py +++ b/tol_lab_share/config/rabbit.py @@ -1,6 +1,4 @@ -import os from lab_share_lib.config.rabbit_config import RabbitConfig, MessageSubjectConfig -from lab_share_lib.config.rabbit_server_details import RabbitServerDetails from tol_lab_share.constants import ( RABBITMQ_SUBJECT_BIOSCAN_POOL_XP_TO_TRACTION, @@ -13,42 +11,11 @@ from tol_lab_share.processors.update_labware_processor import UpdateLabwareProcessor from tol_lab_share.processors.create_aliquot_processor import CreateAliquotProcessor -RABBIT_SERVER_DETAILS = RabbitServerDetails( - uses_ssl=False, - host=os.environ.get("LOCALHOST", "127.0.0.1"), - port=5672, - username=os.environ.get("RABBITMQ_USER", "admin"), - password=os.environ.get("RABBITMQ_PASSWORD", "development"), - vhost="tol", -) - -# In our servers, this will be picked up using deployment project's -# roles/deploy_tol_stack/templates/tol-lab-share/app_config.py.j2 and -# environments/uat/group_vars/tol_swarm_managers.yml -MLWH_ENVIRONMENT_NAME = os.environ.get("MLWH_ENVIRONMENT_NAME", "development") - -WAREHOUSE_RABBIT_SERVER_DETAILS = RabbitServerDetails( - uses_ssl=False, - host=os.environ.get("WAREHOUSE_RMQ_HOST", "127.0.0.1"), - port=5672, - username=os.environ.get("WAREHOUSE_RMQ_USER", "admin"), - password=os.environ.get("WAREHOUSE_RMQ_PASSWORD", "development"), - vhost="test", -) +from .rabbit_servers import TOL_RABBIT_SERVER, ISG_RABBIT_SERVER, MLWH_RABBIT_SERVER RABBITMQ_SERVERS = [ RabbitConfig( - consumer_details=RABBIT_SERVER_DETAILS, - consumed_queue="tls.poolxp-export-to-traction", - message_subjects={ - RABBITMQ_SUBJECT_BIOSCAN_POOL_XP_TO_TRACTION: MessageSubjectConfig( - processor=BioscanPoolXpToTractionProcessor, reader_schema_version="1" - ) - }, - publisher_details=RABBIT_SERVER_DETAILS, - ), - RabbitConfig( - consumer_details=RABBIT_SERVER_DETAILS, + consumer_details=TOL_RABBIT_SERVER, consumed_queue="tol.crud-operations", message_subjects={ RABBITMQ_SUBJECT_CREATE_LABWARE: MessageSubjectConfig( @@ -58,19 +25,26 @@ processor=UpdateLabwareProcessor, reader_schema_version="1" ), }, - publisher_details=RABBIT_SERVER_DETAILS, + publisher_details=TOL_RABBIT_SERVER, ), RabbitConfig( - consumer_details=RABBIT_SERVER_DETAILS, + consumer_details=ISG_RABBIT_SERVER, + consumed_queue="tls.poolxp-export-to-traction", + message_subjects={ + RABBITMQ_SUBJECT_BIOSCAN_POOL_XP_TO_TRACTION: MessageSubjectConfig( + processor=BioscanPoolXpToTractionProcessor, reader_schema_version="1" + ), + }, + publisher_details=ISG_RABBIT_SERVER, + ), + RabbitConfig( + consumer_details=ISG_RABBIT_SERVER, consumed_queue="tls.volume-tracking", message_subjects={ RABBITMQ_SUBJECT_CREATE_ALIQUOT_IN_MLWH: MessageSubjectConfig( processor=CreateAliquotProcessor, reader_schema_version="1" - ) + ), }, - publisher_details=WAREHOUSE_RABBIT_SERVER_DETAILS, + publisher_details=MLWH_RABBIT_SERVER, ), ] - -RABBITMQ_PUBLISH_RETRY_DELAY = 5 -RABBITMQ_PUBLISH_RETRIES = 36 # 3 minutes of retries diff --git a/tol_lab_share/config/rabbit_servers.py b/tol_lab_share/config/rabbit_servers.py new file mode 100644 index 0000000..a7bbdab --- /dev/null +++ b/tol_lab_share/config/rabbit_servers.py @@ -0,0 +1,23 @@ +import os +from lab_share_lib.config.rabbit_server_details import RabbitServerDetails + +MLWH_RABBIT_SERVER = RabbitServerDetails( + uses_ssl=False, + host=os.environ.get("WAREHOUSE_RMQ_HOST", "127.0.0.1"), + port=5672, + username=os.environ.get("WAREHOUSE_RMQ_USER", "admin"), + password=os.environ.get("WAREHOUSE_RMQ_PASSWORD", "development"), + vhost="mlwh", +) + +RABBIT_SERVER_DETAILS = RabbitServerDetails( + uses_ssl=False, + host=os.environ.get("LOCALHOST", "127.0.0.1"), + port=5672, + username=os.environ.get("RABBITMQ_USER", "admin"), + password=os.environ.get("RABBITMQ_PASSWORD", "development"), + vhost="tol", +) + +TOL_RABBIT_SERVER = RABBIT_SERVER_DETAILS +ISG_RABBIT_SERVER = RABBIT_SERVER_DETAILS