diff --git a/codecov/settings_base.py b/codecov/settings_base.py index 5b433a7fb6..620faa4544 100644 --- a/codecov/settings_base.py +++ b/codecov/settings_base.py @@ -1,3 +1,4 @@ +import ast import os from urllib.parse import urlparse @@ -105,6 +106,8 @@ DATABASE_HOST = get_config("services", "database", "host", default="postgres") DATABASE_PORT = get_config("services", "database", "port", default=5432) +DATABASE_OPTIONS = get_config("services", "database", "options", default="{}") + DATABASE_READ_REPLICA_ENABLED = get_config( "setup", "database", "read_replica_enabled", default=False ) @@ -132,6 +135,8 @@ ) DATABASE_READ_PORT = get_config("services", "database_read", "port", default=5432) +DATABASE_READ_OPTIONS = get_config("services", "database_read", "options", default="{}") + TIMESERIES_ENABLED = get_config("setup", "timeseries", "enabled", default=False) TIMESERIES_REAL_TIME_AGGREGATES = get_config( "setup", "timeseries", "real_time_aggregates", default=False @@ -162,6 +167,10 @@ "services", "timeseries_database", "port", default=5432 ) +TIMESERIES_DATABASE_OPTIONS = get_config( + "services", "timeseries_database", "options", default="{}" +) + TIMESERIES_DATABASE_READ_REPLICA_ENABLED = get_config( "setup", "timeseries", "read_replica_enabled", default=False ) @@ -191,6 +200,10 @@ "services", "timeseries_database_read", "port", default=5432 ) +TIMESERIES_DATABASE_READ_OPTIONS = get_config( + "services", "timeseries_database_read", "options", default="{}" +) + # this is the time in seconds django decides to keep the connection open after the request # the default is 0 seconds, meaning django closes the connection after every request # https://docs.djangoproject.com/en/3.1/ref/settings/#conn-max-age @@ -205,6 +218,7 @@ "HOST": DATABASE_HOST, "PORT": DATABASE_PORT, "CONN_MAX_AGE": CONN_MAX_AGE, + "OPTIONS": ast.literal_eval(DATABASE_OPTIONS), } } @@ -217,6 +231,7 @@ "HOST": DATABASE_READ_HOST, "PORT": DATABASE_READ_PORT, "CONN_MAX_AGE": CONN_MAX_AGE, + "OPTIONS": ast.literal_eval(DATABASE_READ_OPTIONS), } if TIMESERIES_ENABLED: @@ -228,6 +243,7 @@ "HOST": TIMESERIES_DATABASE_HOST, "PORT": TIMESERIES_DATABASE_PORT, "CONN_MAX_AGE": CONN_MAX_AGE, + "OPTIONS": ast.literal_eval(TIMESERIES_DATABASE_OPTIONS), } if TIMESERIES_DATABASE_READ_REPLICA_ENABLED: @@ -239,6 +255,7 @@ "HOST": TIMESERIES_DATABASE_READ_HOST, "PORT": TIMESERIES_DATABASE_READ_PORT, "CONN_MAX_AGE": CONN_MAX_AGE, + "OPTIONS": ast.literal_eval(TIMESERIES_DATABASE_READ_OPTIONS), } DATABASE_ROUTERS = ["codecov.db.DatabaseRouter"]