Remove database config parsing from apps.

This commit is contained in:
Erik Johnston 2019-12-06 17:42:18 +00:00
parent 0f3614f0f6
commit bc5cb8bfe8
15 changed files with 18 additions and 75 deletions

View file

@ -97,6 +97,7 @@ from synapse.server_notices.worker_server_notices_sender import (
)
from synapse.state import StateHandler, StateResolutionHandler
from synapse.storage import DataStores, Storage
from synapse.storage.engines import create_engine
from synapse.streams.events import EventSources
from synapse.util import Clock
from synapse.util.distributor import Distributor
@ -209,7 +210,7 @@ class HomeServer(object):
# instantiated during setup() for future return by get_datastore()
DATASTORE_CLASS = abc.abstractproperty()
def __init__(self, hostname, reactor=None, **kwargs):
def __init__(self, hostname, config, reactor=None, **kwargs):
"""
Args:
hostname : The hostname for the server.
@ -219,6 +220,7 @@ class HomeServer(object):
self._reactor = reactor
self.hostname = hostname
self.config = config
self._building = {}
self._listening_services = []
self.start_time = None
@ -229,6 +231,12 @@ class HomeServer(object):
self.admin_redaction_ratelimiter = Ratelimiter()
self.registration_ratelimiter = Ratelimiter()
self.database_engine = create_engine(config.database_config)
config.database_config.setdefault("args", {})[
"cp_openfun"
] = self.database_engine.on_new_connection
self.db_config = config.database_config
self.datastores = None
# Other kwargs are explicit dependencies