diff options
author | Erik Johnston <erik@matrix.org> | 2019-08-20 11:50:12 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-08-20 12:37:08 +0100 |
commit | 74f016d343fe270ab3affe79cc82266d94120e5c (patch) | |
tree | 56dc8be3d54bb97c592722bd3562f5e2a76af08e | |
parent | Fixup _sort_server_list to be slightly more efficient (diff) | |
download | synapse-74f016d343fe270ab3affe79cc82266d94120e5c.tar.xz |
Remove now unused pick_server_from_list
-rw-r--r-- | synapse/http/federation/srv_resolver.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/synapse/http/federation/srv_resolver.py b/synapse/http/federation/srv_resolver.py index 110b112e85..c8ca3fd0e9 100644 --- a/synapse/http/federation/srv_resolver.py +++ b/synapse/http/federation/srv_resolver.py @@ -53,36 +53,6 @@ class Server(object): expires = attr.ib(default=0) -def pick_server_from_list(server_list): - """Randomly choose a server from the server list - - Args: - server_list (list[Server]): list of candidate servers - - Returns: - Tuple[bytes, int]: (host, port) pair for the chosen server - """ - if not server_list: - raise RuntimeError("pick_server_from_list called with empty list") - - # TODO: currently we only use the lowest-priority servers. We should maintain a - # cache of servers known to be "down" and filter them out - - min_priority = min(s.priority for s in server_list) - eligible_servers = list(s for s in server_list if s.priority == min_priority) - total_weight = sum(s.weight for s in eligible_servers) - target_weight = random.randint(0, total_weight) - - for s in eligible_servers: - target_weight -= s.weight - - if target_weight <= 0: - return s.host, s.port - - # this should be impossible. - raise RuntimeError("pick_server_from_list got to end of eligible server list.") - - def _sort_server_list(server_list): """Given a list of SRV records sort them into priority order and shuffle each priority with the given weight. |