diff options
author | Erik Johnston <erik@matrix.org> | 2020-05-13 16:24:59 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2020-05-14 17:25:41 +0100 |
commit | 66c1dff3ba1a52cd32ad6bd9fa355441cfb5f1f8 (patch) | |
tree | 94046c2c7dc4ac57c1fe40ba5383173401d85487 /synapse | |
parent | Make location of events writer configurable (diff) | |
download | synapse-66c1dff3ba1a52cd32ad6bd9fa355441cfb5f1f8.tar.xz |
Use new writers config
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/federation.py | 10 | ||||
-rw-r--r-- | synapse/handlers/message.py | 10 | ||||
-rw-r--r-- | synapse/storage/data_stores/main/events_worker.py | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 81d859f807..236325567d 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -125,10 +125,9 @@ class FederationHandler(BaseHandler): self._server_notices_mxid = hs.config.server_notices_mxid self.config = hs.config self.http_client = hs.get_simple_http_client() + self._instance_name = hs.get_instance_name() - self._send_events_to_master = ReplicationFederationSendEventsRestServlet.make_client( - hs - ) + self._send_events = ReplicationFederationSendEventsRestServlet.make_client(hs) self._notify_user_membership_change = ReplicationUserJoinedLeftRoomRestServlet.make_client( hs ) @@ -2837,8 +2836,9 @@ class FederationHandler(BaseHandler): backfilled: Whether these events are a result of backfilling or not """ - if self.config.worker_app: - await self._send_events_to_master( + if self.config.worker.writers.events != self._instance_name: + await self._send_events( + instance_name=self.config.worker.writers.events, store=self.store, event_and_contexts=event_and_contexts, backfilled=backfilled, diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 0242521cc6..e4c1b8cb00 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -365,10 +365,11 @@ class EventCreationHandler(object): self.notifier = hs.get_notifier() self.config = hs.config self.require_membership_for_aliases = hs.config.require_membership_for_aliases + self._instance_name = hs.get_instance_name() self.room_invite_state_types = self.hs.config.room_invite_state_types - self.send_event_to_master = ReplicationSendEventRestServlet.make_client(hs) + self.send_event = ReplicationSendEventRestServlet.make_client(hs) # This is only used to get at ratelimit function, and maybe_kick_guest_users self.base_handler = BaseHandler(hs) @@ -822,8 +823,9 @@ class EventCreationHandler(object): success = False try: # If we're a worker we need to hit out to the master. - if self.config.worker_app: - await self.send_event_to_master( + if self.config.worker.writers.events != self._instance_name: + await self.send_event( + instance_name=self.config.worker.writers.events, event_id=event.event_id, store=self.store, requester=requester, @@ -888,7 +890,7 @@ class EventCreationHandler(object): This should only be run on master. """ - assert not self.config.worker_app + assert self.config.worker.writers.events == self._instance_name if ratelimit: # We check if this is a room admin redacting an event so that we diff --git a/synapse/storage/data_stores/main/events_worker.py b/synapse/storage/data_stores/main/events_worker.py index 8e0f269721..ecf52565d5 100644 --- a/synapse/storage/data_stores/main/events_worker.py +++ b/synapse/storage/data_stores/main/events_worker.py @@ -76,7 +76,7 @@ class EventsWorkerStore(SQLBaseStore): def __init__(self, database: Database, db_conn, hs): super(EventsWorkerStore, self).__init__(database, db_conn, hs) - if hs.config.worker_app is None: + if hs.config.worker.writers.events == hs.get_instance_name(): self._stream_id_gen = StreamIdGenerator( db_conn, "events", |