diff --git a/amqp/config/amq_configuration.py b/amqp/config/amq_configuration.py index d8be406..2bd4e5a 100644 --- a/amqp/config/amq_configuration.py +++ b/amqp/config/amq_configuration.py @@ -48,6 +48,26 @@ class AMQAdapter: # these 2 shall be provided by Docker swarm, format is a random alphanumeric string self.swarm_service_id = os.getenv("SWARM_SERVICE_ID", default="clever-amqp-service") self.swarm_task_id = os.getenv("SWARM_TASK_ID", default="python-adapter") + # + # Consul related configuration + self.consul_port = config.getint( + "CleverMicro-AMQ", self.PREFIX + "consul-port", + fallback=int(os.getenv("CONSUL_PORT"), 10) if os.getenv("CONSUL_PORT") is not None else 8500 + ) + self.consul_host = config.get( + "CleverMicro-AMQ", + self.PREFIX + "consul-host", + fallback="consul" if os.getenv("CONSUL_HOST") is None else os.getenv("CONSUL_HOST"), + ) + self.consul_port = config.getint( + "CleverMicro-AMQ", self.PREFIX + "consul-max-retries", + fallback=int(os.getenv("CONSUL_MAX_RETRIES"), 10) if os.getenv("CONSUL_MAX_RETRIES") is not None else 5 + ) + self.consul_max_retries = config.getfloat( + "CleverMicro-AMQ", self.PREFIX + "consul-initial-retry-delay", + fallback=float(os.getenv("CONSUL_INITIAL_RETRY_DELAY")) + if os.getenv("CONSUL_INITIAL_RETRY_DELAY") is not None else 0.2, + ) def adapter_prefix(self) -> str: return f"{self.service_name}-{self.generator_id}-"