Skip to content

Commit

Permalink
add wrr lb fallback strategy (#2441)
Browse files Browse the repository at this point in the history
Co-authored-by: jiangyuting <jiangyutingwangyi@163.com>
  • Loading branch information
jiangyt-git and jiangyuting authored Nov 27, 2023
1 parent 713bbb1 commit 3da0a66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/brpc/policy/weighted_round_robin_load_balancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
size_t remain_servers = s->server_list.size();
while (remain_servers > 0) {
SocketId server_id = GetServerInNextStride(s->server_list, filter, tls_temp);
if (!ExcludedServers::IsExcluded(in.excluded, server_id)
if ((remain_servers == 1 // always take last chance
|| !ExcludedServers::IsExcluded(in.excluded, server_id))
&& Socket::Address(server_id, out->ptr) == 0
&& (*out->ptr)->IsAvailable()) {
// update tls.
Expand Down

0 comments on commit 3da0a66

Please sign in to comment.