diff options
author | Patrick Cloke <patrickc@matrix.org> | 2023-04-14 14:08:08 -0400 |
---|---|---|
committer | Patrick Cloke <patrickc@matrix.org> | 2023-05-17 14:26:01 -0400 |
commit | edb91e78b2c52ce939d1b3713ef8f0f7242371ca (patch) | |
tree | d320bbea62cc371b59614cc15b3c7a738bdaa63b | |
parent | Stop passing in the base-store. (diff) | |
download | synapse-edb91e78b2c52ce939d1b3713ef8f0f7242371ca.tar.xz |
Fix-up other users of RelationsWorkerStore.
-rwxr-xr-x | synapse/_scripts/synapse_port_db.py | 23 | ||||
-rw-r--r-- | synapse/app/admin_cmd.py | 4 | ||||
-rw-r--r-- | synapse/app/generic_worker.py | 13 |
3 files changed, 36 insertions, 4 deletions
diff --git a/synapse/_scripts/synapse_port_db.py b/synapse/_scripts/synapse_port_db.py index 27fee3d9a9..b4c9828b9d 100755 --- a/synapse/_scripts/synapse_port_db.py +++ b/synapse/_scripts/synapse_port_db.py @@ -24,6 +24,7 @@ import time import traceback from types import TracebackType from typing import ( + TYPE_CHECKING, Any, Awaitable, Callable, @@ -53,7 +54,12 @@ from synapse.logging.context import ( run_in_background, ) from synapse.notifier import ReplicationNotifier -from synapse.storage.database import DatabasePool, LoggingTransaction, make_conn +from synapse.storage.database import ( + DatabasePool, + LoggingDatabaseConnection, + LoggingTransaction, + make_conn, +) from synapse.storage.databases.main import FilteringWorkerStore, PushRuleStore from synapse.storage.databases.main.account_data import AccountDataWorkerStore from synapse.storage.databases.main.client_ips import ClientIpBackgroundUpdateStore @@ -94,6 +100,9 @@ from synapse.storage.prepare_database import prepare_database from synapse.types import ISynapseReactor from synapse.util import SYNAPSE_VERSION, Clock +if TYPE_CHECKING: + from synapse.server import HomeServer + # Cast safety: Twisted does some naughty magic which replaces the # twisted.internet.reactor module with a Reactor instance at runtime. reactor = cast(ISynapseReactor, reactor_) @@ -238,8 +247,18 @@ class Store( PusherBackgroundUpdatesStore, PresenceBackgroundUpdateStore, ReceiptsBackgroundUpdateStore, - RelationsWorkerStore, ): + def __init__( + self, + database: DatabasePool, + db_conn: LoggingDatabaseConnection, + hs: "HomeServer", + ): + super().__init__(database, db_conn, hs) + + # This is a bit repetitive, but avoids dynamically setting attributes. + self.relations = RelationsWorkerStore(database, db_conn, hs) + def execute(self, f: Callable[..., R], *args: Any, **kwargs: Any) -> Awaitable[R]: return self.db_pool.runInteraction(f.__name__, f, *args, **kwargs) diff --git a/synapse/app/admin_cmd.py b/synapse/app/admin_cmd.py index f9aada269a..3320b11e11 100644 --- a/synapse/app/admin_cmd.py +++ b/synapse/app/admin_cmd.py @@ -75,7 +75,6 @@ class AdminCmdStore( ApplicationServiceTransactionWorkerStore, ApplicationServiceWorkerStore, RoomMemberWorkerStore, - RelationsWorkerStore, EventFederationWorkerStore, EventPushActionsWorkerStore, StateGroupWorkerStore, @@ -101,6 +100,9 @@ class AdminCmdStore( # should refactor it to take a `Clock` directly. self.clock = hs.get_clock() + # This is a bit repetitive, but avoids dynamically setting attributes. + self.relations = RelationsWorkerStore(database, db_conn, hs) + class AdminCmdServer(HomeServer): DATASTORE_CLASS = AdminCmdStore # type: ignore diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index 909ebccf78..6a072db362 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -51,6 +51,7 @@ from synapse.rest.key.v2 import KeyResource from synapse.rest.synapse.client import build_synapse_client_resource_tree from synapse.rest.well_known import well_known_resource from synapse.server import HomeServer +from synapse.storage.database import DatabasePool, LoggingDatabaseConnection from synapse.storage.databases.main.account_data import AccountDataWorkerStore from synapse.storage.databases.main.appservice import ( ApplicationServiceTransactionWorkerStore, @@ -132,7 +133,6 @@ class GenericWorkerStore( ServerMetricsStore, PusherWorkerStore, RoomMemberWorkerStore, - RelationsWorkerStore, EventFederationWorkerStore, EventPushActionsWorkerStore, StateGroupWorkerStore, @@ -152,6 +152,17 @@ class GenericWorkerStore( server_name: str config: HomeServerConfig + def __init__( + self, + database: DatabasePool, + db_conn: LoggingDatabaseConnection, + hs: "HomeServer", + ): + super().__init__(database, db_conn, hs) + + # This is a bit repetitive, but avoids dynamically setting attributes. + self.relations = RelationsWorkerStore(database, db_conn, hs) + class GenericWorkerServer(HomeServer): DATASTORE_CLASS = GenericWorkerStore # type: ignore |