Remove HomeServer.get_datastore() (#12031)

The presence of this method was confusing, and mostly present for backwards
compatibility. Let's get rid of it.

Part of #11733
This commit is contained in:
Richard van der Hoff 2022-02-23 11:04:02 +00:00 committed by GitHub
parent c1ac2a8135
commit e24ff8ebe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
230 changed files with 526 additions and 500 deletions

View file

@ -63,7 +63,7 @@ class ReplicationUserDevicesResyncRestServlet(ReplicationEndpoint):
super().__init__(hs)
self.device_list_updater = hs.get_device_handler().device_list_updater
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
@staticmethod

View file

@ -68,7 +68,7 @@ class ReplicationFederationSendEventsRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.storage = hs.get_storage()
self.clock = hs.get_clock()
self.federation_event_handler = hs.get_federation_event_handler()
@ -167,7 +167,7 @@ class ReplicationFederationSendEduRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.registry = hs.get_federation_registry()
@ -214,7 +214,7 @@ class ReplicationGetQueryRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.registry = hs.get_federation_registry()
@ -260,7 +260,7 @@ class ReplicationCleanRoomRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
@staticmethod
async def _serialize_payload(room_id: str) -> JsonDict: # type: ignore[override]
@ -297,7 +297,7 @@ class ReplicationStoreRoomOnOutlierMembershipRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
@staticmethod
async def _serialize_payload(room_id: str, room_version: RoomVersion) -> JsonDict: # type: ignore[override]

View file

@ -50,7 +50,7 @@ class ReplicationRemoteJoinRestServlet(ReplicationEndpoint):
super().__init__(hs)
self.federation_handler = hs.get_federation_handler()
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
@staticmethod
@ -119,7 +119,7 @@ class ReplicationRemoteKnockRestServlet(ReplicationEndpoint):
super().__init__(hs)
self.federation_handler = hs.get_federation_handler()
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
@staticmethod
@ -188,7 +188,7 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.member_handler = hs.get_room_member_handler()
@ -258,7 +258,7 @@ class ReplicationRemoteRescindKnockRestServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.member_handler = hs.get_room_member_handler()
@ -325,7 +325,7 @@ class ReplicationUserJoinedLeftRoomRestServlet(ReplicationEndpoint):
super().__init__(hs)
self.registeration_handler = hs.get_registration_handler()
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.distributor = hs.get_distributor()

View file

@ -36,7 +36,7 @@ class ReplicationRegisterServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.registration_handler = hs.get_registration_handler()
@staticmethod
@ -112,7 +112,7 @@ class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
def __init__(self, hs: "HomeServer"):
super().__init__(hs)
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.registration_handler = hs.get_registration_handler()
@staticmethod

View file

@ -69,7 +69,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
super().__init__(hs)
self.event_creation_handler = hs.get_event_creation_handler()
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.storage = hs.get_storage()
self.clock = hs.get_clock()

View file

@ -111,7 +111,7 @@ class ReplicationDataHandler:
"""
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.notifier = hs.get_notifier()
self._reactor = hs.get_reactor()
self._clock = hs.get_clock()
@ -340,7 +340,7 @@ class FederationSenderHandler:
def __init__(self, hs: "HomeServer"):
assert hs.should_send_federation()
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self._is_mine_id = hs.is_mine_id
self._hs = hs

View file

@ -95,7 +95,7 @@ class ReplicationCommandHandler:
def __init__(self, hs: "HomeServer"):
self._replication_data_handler = hs.get_replication_data_handler()
self._presence_handler = hs.get_presence_handler()
self._store = hs.get_datastore()
self._store = hs.get_datastores().main
self._notifier = hs.get_notifier()
self._clock = hs.get_clock()
self._instance_id = hs.get_instance_id()

View file

@ -72,7 +72,7 @@ class ReplicationStreamer:
"""
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
self.clock = hs.get_clock()
self.notifier = hs.get_notifier()
self._instance_name = hs.get_instance_name()

View file

@ -239,7 +239,7 @@ class BackfillStream(Stream):
ROW_TYPE = BackfillStreamRow
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
self._current_token,
@ -267,7 +267,7 @@ class PresenceStream(Stream):
ROW_TYPE = PresenceStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
if hs.get_instance_name() in hs.config.worker.writers.presence:
# on the presence writer, query the presence handler
@ -355,7 +355,7 @@ class ReceiptsStream(Stream):
ROW_TYPE = ReceiptsStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_max_receipt_stream_id),
@ -374,7 +374,7 @@ class PushRulesStream(Stream):
ROW_TYPE = PushRulesStreamRow
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
@ -401,7 +401,7 @@ class PushersStream(Stream):
ROW_TYPE = PushersStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
@ -434,7 +434,7 @@ class CachesStream(Stream):
ROW_TYPE = CachesStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
store.get_cache_stream_token_for_writer,
@ -455,7 +455,7 @@ class DeviceListsStream(Stream):
ROW_TYPE = DeviceListsStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_device_stream_token),
@ -474,7 +474,7 @@ class ToDeviceStream(Stream):
ROW_TYPE = ToDeviceStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_to_device_stream_token),
@ -495,7 +495,7 @@ class TagAccountDataStream(Stream):
ROW_TYPE = TagAccountDataStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_max_account_data_stream_id),
@ -516,7 +516,7 @@ class AccountDataStream(Stream):
ROW_TYPE = AccountDataStreamRow
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastore()
self.store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(self.store.get_max_account_data_stream_id),
@ -585,7 +585,7 @@ class GroupServerStream(Stream):
ROW_TYPE = GroupsStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_group_stream_token),
@ -604,7 +604,7 @@ class UserSignatureStream(Stream):
ROW_TYPE = UserSignatureStreamRow
def __init__(self, hs: "HomeServer"):
store = hs.get_datastore()
store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
current_token_without_instance(store.get_device_stream_token),

View file

@ -124,7 +124,7 @@ class EventsStream(Stream):
NAME = "events"
def __init__(self, hs: "HomeServer"):
self._store = hs.get_datastore()
self._store = hs.get_datastores().main
super().__init__(
hs.get_instance_name(),
self._store._stream_id_gen.get_current_token_for_writer,