diff options
author | Erik Johnston <erik@matrix.org> | 2020-08-11 22:32:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 22:32:14 +0100 |
commit | 6ba621d78657bab1c17f6f612dd43a64cfb8921e (patch) | |
tree | 5f30e655165f4b2a5e2e35fce739de0155e0de2f /synapse/storage/databases | |
parent | Convert tags and metrics databases to async/await (#8062) (diff) | |
parent | Merge remote-tracking branch 'origin/develop' into erikj/type_server (diff) | |
download | synapse-6ba621d78657bab1c17f6f612dd43a64cfb8921e.tar.xz |
Merge pull request #8060 from matrix-org/erikj/type_server
Change HomeServer definition to work with typing.
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r-- | synapse/storage/databases/__init__.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/synapse/storage/databases/__init__.py b/synapse/storage/databases/__init__.py index b163eebf39..4406e58273 100644 --- a/synapse/storage/databases/__init__.py +++ b/synapse/storage/databases/__init__.py @@ -38,9 +38,9 @@ class Databases(object): # store. self.databases = [] - self.main = None - self.state = None - self.persist_events = None + main = None + state = None + persist_events = None for database_config in hs.config.database.databases: db_name = database_config.name @@ -61,27 +61,25 @@ class Databases(object): # Sanity check we don't try and configure the main store on # multiple databases. - if self.main: + if main: raise Exception("'main' data store already configured") - self.main = main_store_class(database, db_conn, hs) + main = main_store_class(database, db_conn, hs) # If we're on a process that can persist events also # instantiate a `PersistEventsStore` if hs.config.worker.writers.events == hs.get_instance_name(): - self.persist_events = PersistEventsStore( - hs, database, self.main - ) + persist_events = PersistEventsStore(hs, database, main) if "state" in database_config.databases: logger.info("Starting 'state' data store") # Sanity check we don't try and configure the state store on # multiple databases. - if self.state: + if state: raise Exception("'state' data store already configured") - self.state = StateGroupDataStore(database, db_conn, hs) + state = StateGroupDataStore(database, db_conn, hs) db_conn.commit() @@ -90,8 +88,14 @@ class Databases(object): logger.info("Database %r prepared", db_name) # Sanity check that we have actually configured all the required stores. - if not self.main: + if not main: raise Exception("No 'main' data store configured") - if not self.state: + if not state: raise Exception("No 'main' data store configured") + + # We use local variables here to ensure that the databases do not have + # optional types. + self.main = main + self.state = state + self.persist_events = persist_events |