diff --git a/requirements.txt b/requirements.txt index 3906e69..29f2c37 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,6 @@ graphql-core==2.2.1 gql==0.1.0 cryptography==3.1 redis==3.5.3 -eiffellib==1.2.0 +eiffellib[rabbitmq]==2.2.0 pydantic==1.6 python-box==5.2.0 diff --git a/setup.cfg b/setup.cfg index a355e27..2c8c300 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ install_requires = gql==0.1.0 cryptography==3.1 redis==3.5.3 - eiffellib==1.2.0 + eiffellib[rabbitmq]==2.2.0 pydantic==1.6 requests==2.24.0 kubernetes==7.0.1 diff --git a/src/etos_lib/etos.py b/src/etos_lib/etos.py index 7f17ac0..e7a6fa9 100644 --- a/src/etos_lib/etos.py +++ b/src/etos_lib/etos.py @@ -49,9 +49,12 @@ class ETOS: # pylint: disable=too-many-instance-attributes __secrets = None __database = None - def __init__(self, service_name, host, name): + def __init__(self, service_name, host, name, domain_id=None): """Initialize source and service name.""" - self.config.set("source", {"name": name, "host": host}) + source = {"name": name, "host": host} + if domain_id is not None: + source["domainId"] = domain_id + self.config.set("source", source) self.config.set("service_name", service_name) def __del__(self): @@ -64,7 +67,7 @@ def start_publisher(self): rabbitmq = self.config.get("rabbitmq_publisher") if not rabbitmq: raise PublisherConfigurationMissing - self.publisher = RabbitMQPublisher(**rabbitmq) + self.publisher = RabbitMQPublisher(routing_key=None, **rabbitmq) if not self.debug.disable_sending_events: self.publisher.start() self.config.set("publisher", self.publisher) diff --git a/src/etos_lib/lib/config.py b/src/etos_lib/lib/config.py index da5cf2c..c0adc3f 100644 --- a/src/etos_lib/lib/config.py +++ b/src/etos_lib/lib/config.py @@ -96,7 +96,10 @@ def rabbitmq_subscriber_from_environment(self): """Load RabbitMQ subscriber data from environment variables and set in config.""" if not self.get("rabbitmq"): self.rabbitmq_from_environment() - data = {"queue": os.getenv("RABBITMQ_QUEUE", None), "routing_key": "#"} + data = { + "queue": os.getenv("RABBITMQ_QUEUE", None), + "routing_key": os.getenv("RABBITMQ_ROUTING_KEY", "#") + } data.update(**self.get("rabbitmq").copy()) self.set("rabbitmq_subscriber", data)