diff options
author | David Baker <dbkr@users.noreply.github.com> | 2016-06-01 15:32:52 +0100 |
---|---|---|
committer | David Baker <dbkr@users.noreply.github.com> | 2016-06-01 15:32:52 +0100 |
commit | 00c487a8dbba7b7767ed207dcf835d4cb408ccd9 (patch) | |
tree | d0510818ac8d57ecfb7f6b6cf33c20676fd14060 /synapse/federation/federation_client.py | |
parent | Merge pull request #810 from matrix-org/dbkr/limit_email_notifs (diff) | |
parent | Inject fake room list handler in tests (diff) | |
download | synapse-00c487a8dbba7b7767ed207dcf835d4cb408ccd9.tar.xz |
Merge pull request #808 from matrix-org/dbkr/room_list_spider
Add secondary_directory_servers option to fetch room list from other servers
Diffstat (limited to 'synapse/federation/federation_client.py')
-rw-r--r-- | synapse/federation/federation_client.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 37ee469fa2..d835c1b038 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -24,6 +24,7 @@ from synapse.api.errors import ( CodeMessageException, HttpResponseException, SynapseError, ) from synapse.util import unwrapFirstError +from synapse.util.async import concurrently_execute from synapse.util.caches.expiringcache import ExpiringCache from synapse.util.logutils import log_function from synapse.events import FrozenEvent @@ -551,6 +552,25 @@ class FederationClient(FederationBase): raise RuntimeError("Failed to send to any server.") @defer.inlineCallbacks + def get_public_rooms(self, destinations): + results_by_server = {} + + @defer.inlineCallbacks + def _get_result(s): + if s == self.server_name: + defer.returnValue() + + try: + result = yield self.transport_layer.get_public_rooms(s) + results_by_server[s] = result + except: + logger.exception("Error getting room list from server %r", s) + + yield concurrently_execute(_get_result, destinations, 3) + + defer.returnValue(results_by_server) + + @defer.inlineCallbacks def query_auth(self, destination, room_id, event_id, local_auth): """ Params: |