This is an automated email from the ASF dual-hosted git repository.

wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 3da0a66c add wrr lb fallback strategy (#2441)
3da0a66c is described below

commit 3da0a66c0cba0a19ac912dd474d90b96a7105440
Author: jiangyt-git <64257436+jiangyt-...@users.noreply.github.com>
AuthorDate: Mon Nov 27 17:19:34 2023 +0800

    add wrr lb fallback strategy (#2441)
    
    Co-authored-by: jiangyuting <jiangyutingwan...@163.com>
---
 src/brpc/policy/weighted_round_robin_load_balancer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp 
b/src/brpc/policy/weighted_round_robin_load_balancer.cpp
index eefc11d4..2a98e7fb 100644
--- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp
+++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp
@@ -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.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to