From 761e9cb69ab413d19508536b63a286cd2ca9f530 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 f396ff04..95fee89d 100644 --- a/adapter/outboundgroup/loadbalance.go +++ b/adapter/outboundgroup/loadbalance.go @@ -127,6 +127,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] } }