summary refs log tree commit diff
path: root/synapse/handlers/profile.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-08-17 11:43:16 +0100
committerErik Johnston <erik@matrix.org>2018-08-17 14:15:14 +0100
commitca87ad1defac1082462367854cb4a656b7a96e90 (patch)
tree984d755964805ec8bf6afade36645b93097d811a /synapse/handlers/profile.py
parentRemote profile cache should remain in master worker (diff)
downloadsynapse-ca87ad1defac1082462367854cb4a656b7a96e90.tar.xz
Split ProfileHandler into master and worker
Diffstat (limited to 'synapse/handlers/profile.py')
-rw-r--r--synapse/handlers/profile.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index 6d1fbb1a5c..8b349f6ad6 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -33,12 +33,12 @@ from ._base import BaseHandler
 logger = logging.getLogger(__name__)
 
 
-class ProfileHandler(BaseHandler):
+class WorkerProfileHandler(BaseHandler):
     PROFILE_UPDATE_MS = 60 * 1000
     PROFILE_UPDATE_EVERY_MS = 24 * 60 * 60 * 1000
 
     def __init__(self, hs):
-        super(ProfileHandler, self).__init__(hs)
+        super(WorkerProfileHandler, self).__init__(hs)
 
         self.federation = hs.get_federation_client()
         hs.get_federation_registry().register_query_handler(
@@ -47,11 +47,6 @@ class ProfileHandler(BaseHandler):
 
         self.user_directory_handler = hs.get_user_directory_handler()
 
-        if hs.config.worker_app is None:
-            self.clock.looping_call(
-                self._start_update_remote_profile_cache, self.PROFILE_UPDATE_MS,
-            )
-
         self._notify_master_profile_change = (
             ReplicationHandleProfileChangeRestServlet.make_client(hs)
         )
@@ -298,6 +293,18 @@ class ProfileHandler(BaseHandler):
                     room_id, str(e.message)
                 )
 
+
+class MasterProfileHandler(WorkerProfileHandler):
+    PROFILE_UPDATE_MS = 60 * 1000
+    PROFILE_UPDATE_EVERY_MS = 24 * 60 * 60 * 1000
+
+    def __init__(self, hs):
+        super(MasterProfileHandler, self).__init__(hs)
+
+        self.clock.looping_call(
+            self._start_update_remote_profile_cache, self.PROFILE_UPDATE_MS,
+        )
+
     def _start_update_remote_profile_cache(self):
         return run_as_background_process(
             "Update remote profile", self._update_remote_profile_cache,