diff --git a/lib/SyTest/Homeserver/Synapse.pm b/lib/SyTest/Homeserver/Synapse.pm index 9d826493b..9da4a78a0 100644 --- a/lib/SyTest/Homeserver/Synapse.pm +++ b/lib/SyTest/Homeserver/Synapse.pm @@ -307,10 +307,19 @@ sub start host => "$bind_host", port => $self->{ports}{event_persister2}, }, + "client_reader" => { + host => "$bind_host", + port => $self->{ports}{client_reader}, + }, }, stream_writers => { events => $self->{redis_host} ne '' ? [ "event_persister1", "event_persister2" ] : "master", + + # There's no particular reason to choose client_reader, but I + # couldn't think of a better place and I'm not sure we want to add + # more workers at this point + to_device => $self->{redis_host} ne '' ? [ "client_reader" ] : "master", }, # We use a high limit so the limit is never reached, but enabling the @@ -847,7 +856,7 @@ sub _start_synapse "worker_listeners" => [ { type => "http", - resources => [{ names => ["client"] }], + resources => [{ names => ["client", "replication"] }], port => $self->{ports}{client_reader}, bind_address => $bind_host, }, @@ -1189,7 +1198,12 @@ EOCONFIG sub generate_haproxy_map { - return <<'EOCONFIG'; + my $self = shift; + + # The base haproxy routes. Note that we add more routes below if using + # haproxy. Also, the routing for GET requests below takes precedence over + # these routes. + my $haproxy_map = <<'EOCONFIG'; ^/_matrix/client/(v2_alpha|r0)/sync$ synchrotron ^/_matrix/client/(api/v1|v2_alpha|r0)/events$ synchrotron ^/_matrix/client/(api/v1|r0)/initialSync$ synchrotron @@ -1247,6 +1261,17 @@ sub generate_haproxy_map ^/_matrix/client/(api/v1|r0|unstable)/profile/ event_creator EOCONFIG + + # Some things can only be moved off master when using redis. + if ( $self->{redis_host} ne '' ) { + $haproxy_map .= <<'EOCONFIG'; + +^/_matrix/client/(api/v1|r0|unstable)/sendToDevice/ client_reader + +EOCONFIG + } + + return $haproxy_map } sub generate_haproxy_get_map