Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring config files #140

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tol_lab_share/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
58 changes: 16 additions & 42 deletions tol_lab_share/config/rabbit.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
Expand All @@ -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
23 changes: 23 additions & 0 deletions tol_lab_share/config/rabbit_servers.py
Original file line number Diff line number Diff line change
@@ -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
Loading