summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-02-05 17:22:16 +0000
committerErik Johnston <erik@matrix.org>2018-02-07 10:32:32 +0000
commit24dd73028ad7fc7a5109a5d97eef5a79179225d4 (patch)
tree67f3f226cf5174a4a7227228acd4ec2ccb05966b /synapse/handlers/message.py
parentRemove pointless ratelimit check (diff)
downloadsynapse-24dd73028ad7fc7a5109a5d97eef5a79179225d4.tar.xz
Add replication http endpoint for event sending
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py

index a58fc37fff..92c153f300 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py
@@ -28,6 +28,7 @@ from synapse.util.logcontext import preserve_fn from synapse.util.metrics import measure_func from synapse.util.frozenutils import unfreeze from synapse.visibility import filter_events_for_client +from synapse.replication.http.send_event import send_event_to_master from ._base import BaseHandler @@ -312,6 +313,9 @@ class EventCreationHandler(object): self.server_name = hs.hostname self.ratelimiter = hs.get_ratelimiter() self.notifier = hs.get_notifier() + self.config = hs.config + + self.http_client = hs.get_simple_http_client() # This is only used to get at ratelimit function, and maybe_kick_guest_users self.base_handler = BaseHandler(hs) @@ -559,6 +563,18 @@ class EventCreationHandler(object): ): # We now need to go and hit out to wherever we need to hit out to. + # If we're a worker we need to hit out to the master. + if self.config.worker_app: + yield send_event_to_master( + self.http_client, + host=self.config.worker_replication_host, + port=self.config.worker_replication_http_port, + requester=requester, + event=event, + context=context, + ) + return + if ratelimit: yield self.base_handler.ratelimit(requester)