From 5e03be2fb959b2ac5793080adb3bcd0ba561bdba Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 4 Jul 2022 21:36:33 +0800 Subject: [PATCH] Chore: load balance hash need to have fallback strategy --- adapter/outboundgroup/loadbalance.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/adapter/outboundgroup/loadbalance.go b/adapter/outboundgroup/loadbalance.go index 5b962983..6d544a5d 100644 --- a/adapter/outboundgroup/loadbalance.go +++ b/adapter/outboundgroup/loadbalance.go @@ -145,6 +145,13 @@ func strategyConsistentHashing() strategyFn { } } + // when availability is poor, traverse the entire list to get the available nodes + for _, proxy := range proxies { + if proxy.Alive() { + return proxy + } + } + return proxies[0] } }