mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 17:56:19 +03:00
Join via closest server
This commit is contained in:
parent
781bd4fb96
commit
e8be4ca1ad
3 changed files with 24 additions and 6 deletions
|
@ -486,6 +486,22 @@ class FederationClient(FederationBase):
|
|||
|
||||
RuntimeError if no servers were reachable.
|
||||
"""
|
||||
healths = yield self.store.get_destination_healths(destinations)
|
||||
|
||||
with_healths = []
|
||||
without_healths = []
|
||||
for d in destinations:
|
||||
if healths.get(d):
|
||||
with_healths.append(d)
|
||||
else:
|
||||
without_healths.append(d)
|
||||
|
||||
with_healths.sort(key=lambda d: healths[d])
|
||||
|
||||
destinations = with_healths + without_healths
|
||||
|
||||
logger.info("Trying destinations: %r", destinations)
|
||||
|
||||
for destination in destinations:
|
||||
if destination == self.server_name:
|
||||
continue
|
||||
|
|
|
@ -265,9 +265,8 @@ class DirectoryHandler(BaseHandler):
|
|||
Codes.NOT_FOUND
|
||||
)
|
||||
|
||||
users = yield self.state.get_current_user_in_room(room_id)
|
||||
extra_servers = set(get_domain_from_id(u) for u in users)
|
||||
servers = set(extra_servers) | set(servers)
|
||||
hosts = yield self.state.get_current_hosts_in_room(room_id)
|
||||
servers = set(hosts) | set(servers)
|
||||
|
||||
# If this server is in the list of servers, return it first.
|
||||
if self.server_name in servers:
|
||||
|
@ -278,6 +277,8 @@ class DirectoryHandler(BaseHandler):
|
|||
else:
|
||||
servers = list(servers)
|
||||
|
||||
logger.info("Returning servers %s", servers)
|
||||
|
||||
defer.returnValue({
|
||||
"room_id": room_id,
|
||||
"servers": servers,
|
||||
|
@ -292,14 +293,14 @@ class DirectoryHandler(BaseHandler):
|
|||
400, "Room Alias is not hosted on this Home Server"
|
||||
)
|
||||
|
||||
result = yield self.get_association_from_room_alias(
|
||||
result = yield self.get_association(
|
||||
room_alias
|
||||
)
|
||||
|
||||
if result is not None:
|
||||
defer.returnValue({
|
||||
"room_id": result.room_id,
|
||||
"servers": result.servers,
|
||||
"room_id": result["room_id"],
|
||||
"servers": result["servers"],
|
||||
})
|
||||
else:
|
||||
raise SynapseError(
|
||||
|
|
|
@ -1155,6 +1155,7 @@ class FederationHandler(BaseHandler):
|
|||
have finished processing the join.
|
||||
"""
|
||||
logger.debug("Joining %s to %s", joinee, room_id)
|
||||
logger.info("Target hosts %s", target_hosts)
|
||||
|
||||
origin, event = yield self._make_and_verify_event(
|
||||
target_hosts,
|
||||
|
|
Loading…
Reference in a new issue