Skip to content

Commit

Permalink
run checks for all necessary configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
bgunnar5 committed Sep 17, 2024
1 parent ce8bf37 commit 5851d9d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions merlin/managers/redis_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def get_redis_connection(self) -> redis.Redis:
from merlin.config.results_backend import get_backend_password # pylint: disable=import-outside-toplevel

password_file = CONFIG.results_backend.password if hasattr(CONFIG.results_backend, "password") else None
server = CONFIG.results_backend.server if hasattr(CONFIG.results_backend, "server") else None
port = CONFIG.results_backend.port if hasattr(CONFIG.results_backend, "port") else None
results_db_num = CONFIG.results_backend.db_num if hasattr(CONFIG.results_backend, "db_num") else None
username = CONFIG.results_backend.username if hasattr(CONFIG.results_backend, "username") else None
has_ssl = hasattr(CONFIG.results_backend, "cert_reqs")
ssl_cert_reqs = CONFIG.results_backend.cert_reqs if has_ssl else "required"

password = None
if password_file is not None:
Expand All @@ -76,16 +82,11 @@ def get_redis_connection(self) -> redis.Redis:
if hasattr(CONFIG.results_backend, "password"):
password = CONFIG.results_backend.password

has_ssl = hasattr(CONFIG.results_backend, "cert_reqs")
ssl_cert_reqs = "required"
if has_ssl:
ssl_cert_reqs = CONFIG.results_backend.cert_reqs

return redis.Redis(
host=CONFIG.results_backend.server,
port=CONFIG.results_backend.port,
db=CONFIG.results_backend.db_num + self.db_num, # Increment db_num to avoid conflicts
username=CONFIG.results_backend.username,
host=server,
port=port,
db=results_db_num + self.db_num, # Increment db_num to avoid conflicts
username=username,
password=password,
decode_responses=True,
ssl=has_ssl,
Expand Down

0 comments on commit 5851d9d

Please sign in to comment.