diff options
author | Erik Johnston <erik@matrix.org> | 2020-05-14 14:00:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 14:00:58 +0100 |
commit | 1de36407d14d7517af8462b2608dff0ea657262e (patch) | |
tree | 4b747ddfa019aa53667d01bb421f4df9698fd539 /synapse/replication/http | |
parent | Merge tag 'v1.13.0rc2' into develop (diff) | |
download | synapse-1de36407d14d7517af8462b2608dff0ea657262e.tar.xz |
Add `instance_map` config and route replication calls (#7495)
Diffstat (limited to 'synapse/replication/http')
-rw-r--r-- | synapse/replication/http/_base.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/synapse/replication/http/_base.py b/synapse/replication/http/_base.py index f88c80ae84..c3136a4eb9 100644 --- a/synapse/replication/http/_base.py +++ b/synapse/replication/http/_base.py @@ -141,17 +141,26 @@ class ReplicationEndpoint(object): Returns a callable that accepts the same parameters as `_serialize_payload`. """ clock = hs.get_clock() - host = hs.config.worker_replication_host - port = hs.config.worker_replication_http_port - client = hs.get_simple_http_client() + master_host = hs.config.worker_replication_host + master_port = hs.config.worker_replication_http_port + + instance_map = hs.config.worker.instance_map + @trace(opname="outgoing_replication_request") @defer.inlineCallbacks def send_request(instance_name="master", **kwargs): - # Currently we only support sending requests to master process. - if instance_name != "master": - raise Exception("Unknown instance") + if instance_name == "master": + host = master_host + port = master_port + elif instance_name in instance_map: + host = instance_map[instance_name].host + port = instance_map[instance_name].port + else: + raise Exception( + "Instance %r not in 'instance_map' config" % (instance_name,) + ) data = yield cls._serialize_payload(**kwargs) |