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

Allow the 'db' config section to be defined #100

Merged
merged 6 commits into from
May 12, 2020
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
1 change: 1 addition & 0 deletions changelog.d/100.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sygnal will no longer warn about the 'database' config field being not understood.
15 changes: 13 additions & 2 deletions sygnal/sygnal.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"sentry": {"enabled": False},
},
"apps": {},
# This is defined so the key is known to check_config, but it will not
# define a default value.
"database": None,
}


Expand Down Expand Up @@ -155,7 +158,7 @@ def __init__(self, config, custom_reactor, tracer=opentracing.tracer):
check_same_thread=False,
)
else:
raise Exception("Unsupported database 'name'")
raise Exception("Unsupported database '%s'" % db_name)

async def _make_pushkin(self, app_name, app_config):
"""
Expand Down Expand Up @@ -273,7 +276,15 @@ def check_section(section_name, known_keys, cfgpart=config):
"prometheus", {"enabled", "address", "port"}, cfgpart=config["metrics"]
)
check_section("sentry", {"enabled", "dsn"}, cfgpart=config["metrics"])
check_section("database", {"name", "args"})

# If 'db' is defined, it will override the 'database' config.
if "db" in config:
logger.warning(
"""The 'db' config field has been replaced by 'database'.
See the sample config for help."""
)
else:
check_section("database", {"name", "args"})


def merge_left_with_defaults(defaults, loaded_config):
Expand Down