From 69e1734e3a129414db1ca12147cf51c05ffa25ba Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:49:11 -0400 Subject: [PATCH] Apply FallbackTag to leastping and roundrobin --- app/router/config.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/router/config.go b/app/router/config.go index 28ba7e31..ce4ed270 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -126,15 +126,17 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch switch strings.ToLower(br.Strategy) { case "leastping": return &Balancer{ - selectors: br.OutboundSelector, - strategy: &LeastPingStrategy{}, - ohm: ohm, + selectors: br.OutboundSelector, + strategy: &LeastPingStrategy{}, + fallbackTag: br.FallbackTag, + ohm: ohm, }, nil case "roundrobin": return &Balancer{ - selectors: br.OutboundSelector, - strategy: &RoundRobinStrategy{}, - ohm: ohm, + selectors: br.OutboundSelector, + strategy: &RoundRobinStrategy{}, + fallbackTag: br.FallbackTag, + ohm: ohm, }, nil case "leastload": i, err := br.StrategySettings.GetInstance() @@ -147,17 +149,19 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch } leastLoadStrategy := NewLeastLoadStrategy(s) return &Balancer{ - selectors: br.OutboundSelector, - ohm: ohm, fallbackTag: br.FallbackTag, - strategy: leastLoadStrategy, + selectors: br.OutboundSelector, + ohm: ohm, + fallbackTag: br.FallbackTag, + strategy: leastLoadStrategy, }, nil case "random": fallthrough case "": return &Balancer{ - selectors: br.OutboundSelector, - ohm: ohm, fallbackTag: br.FallbackTag, - strategy: &RandomStrategy{}, + selectors: br.OutboundSelector, + ohm: ohm, + fallbackTag: br.FallbackTag, + strategy: &RandomStrategy{}, }, nil default: return nil, newError("unrecognized balancer type")