From 29c5d306f6fe3dc72c9531b953f6aff99e69ee37 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 1 May 2020 14:06:33 +0100 Subject: [PATCH 1/3] Allow ReplicationRestResource to be added to workers --- synapse/app/generic_worker.py | 4 ++++ synapse/replication/http/__init__.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index 2e3add7ac571..1b51ccb11aea 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -47,6 +47,7 @@ from synapse.logging.context import LoggingContext from synapse.metrics import METRICS_PREFIX, MetricsResource, RegistryProxy from synapse.metrics.background_process_metrics import run_as_background_process +from synapse.replication.http import REPLICATION_PREFIX, ReplicationRestResource from synapse.replication.slave.storage._base import BaseSlavedStore from synapse.replication.slave.storage.account_data import SlavedAccountDataStore from synapse.replication.slave.storage.appservice import SlavedApplicationServiceStore @@ -568,6 +569,9 @@ def _listen_http(self, listener_config): if name in ["keys", "federation"]: resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self) + if name == "replication": + resources[REPLICATION_PREFIX] = ReplicationRestResource(self) + root_resource = create_resource_tree(resources, NoResource()) _base.listen_tcp( diff --git a/synapse/replication/http/__init__.py b/synapse/replication/http/__init__.py index 4613b2538ce8..83d41cce0ad8 100644 --- a/synapse/replication/http/__init__.py +++ b/synapse/replication/http/__init__.py @@ -34,9 +34,12 @@ def __init__(self, hs): def register_servlets(self, hs): send_event.register_servlets(hs, self) - membership.register_servlets(hs, self) federation.register_servlets(hs, self) - login.register_servlets(hs, self) - register.register_servlets(hs, self) - devices.register_servlets(hs, self) - streams.register_servlets(hs, self) + + # The following can't currently be instansiated on master. + if hs.config.worker.worker_app is None: + membership.register_servlets(hs, self) + login.register_servlets(hs, self) + register.register_servlets(hs, self) + devices.register_servlets(hs, self) + streams.register_servlets(hs, self) From d269d93495da60250de6a7f0f43305eff0a56d09 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 15 May 2020 16:16:16 +0100 Subject: [PATCH 2/3] Newsfile --- changelog.d/7515.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7515.misc diff --git a/changelog.d/7515.misc b/changelog.d/7515.misc new file mode 100644 index 000000000000..48f3044f90c8 --- /dev/null +++ b/changelog.d/7515.misc @@ -0,0 +1 @@ +Allow `ReplicationRestResource` to be added to workers. From 56d41a2f8b488d18580bba6c475bc0ecd0f56652 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 18 May 2020 11:58:36 +0100 Subject: [PATCH 3/3] fix comment --- synapse/replication/http/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/replication/http/__init__.py b/synapse/replication/http/__init__.py index 83d41cce0ad8..a909744e9345 100644 --- a/synapse/replication/http/__init__.py +++ b/synapse/replication/http/__init__.py @@ -36,7 +36,7 @@ def register_servlets(self, hs): send_event.register_servlets(hs, self) federation.register_servlets(hs, self) - # The following can't currently be instansiated on master. + # The following can't currently be instantiated on workers. if hs.config.worker.worker_app is None: membership.register_servlets(hs, self) login.register_servlets(hs, self)