diff options
author | Erik Johnston <erik@matrix.org> | 2019-12-12 10:37:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-12 10:37:56 +0000 |
commit | b8e4b39b69562cc0377ada84682752c1ad5e949d (patch) | |
tree | 009e2b01d37ddd86883f5ac04608d836217303c0 /synapse/server.py | |
parent | Add `include_event_in_state` to _get_state_for_room (#6521) (diff) | |
parent | Add new config param to docstring and add types (diff) | |
download | synapse-b8e4b39b69562cc0377ada84682752c1ad5e949d.tar.xz |
Merge pull request #6511 from matrix-org/erikj/remove_db_config_from_apps
Move database config from apps into HomeServer object
Diffstat (limited to 'synapse/server.py')
-rw-r--r-- | synapse/server.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/server.py b/synapse/server.py index 2db3dab221..5021068ce0 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -34,6 +34,7 @@ from synapse.api.filtering import Filtering from synapse.api.ratelimiting import Ratelimiter from synapse.appservice.api import ApplicationServiceApi from synapse.appservice.scheduler import ApplicationServiceScheduler +from synapse.config.homeserver import HomeServerConfig from synapse.crypto import context_factory from synapse.crypto.keyring import Keyring from synapse.events.builder import EventBuilderFactory @@ -97,6 +98,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,16 +211,18 @@ 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: str, config: HomeServerConfig, reactor=None, **kwargs): """ Args: hostname : The hostname for the server. + config: The full config for the homeserver. """ if not reactor: from twisted.internet import reactor self._reactor = reactor self.hostname = hostname + self.config = config self._building = {} self._listening_services = [] self.start_time = None @@ -229,6 +233,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 |