|
|
@ -126,15 +126,17 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch
|
|
|
|
switch strings.ToLower(br.Strategy) {
|
|
|
|
switch strings.ToLower(br.Strategy) {
|
|
|
|
case "leastping":
|
|
|
|
case "leastping":
|
|
|
|
return &Balancer{
|
|
|
|
return &Balancer{
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
strategy: &LeastPingStrategy{},
|
|
|
|
strategy: &LeastPingStrategy{},
|
|
|
|
ohm: ohm,
|
|
|
|
fallbackTag: br.FallbackTag,
|
|
|
|
|
|
|
|
ohm: ohm,
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
case "roundrobin":
|
|
|
|
case "roundrobin":
|
|
|
|
return &Balancer{
|
|
|
|
return &Balancer{
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
strategy: &RoundRobinStrategy{},
|
|
|
|
strategy: &RoundRobinStrategy{},
|
|
|
|
ohm: ohm,
|
|
|
|
fallbackTag: br.FallbackTag,
|
|
|
|
|
|
|
|
ohm: ohm,
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
case "leastload":
|
|
|
|
case "leastload":
|
|
|
|
i, err := br.StrategySettings.GetInstance()
|
|
|
|
i, err := br.StrategySettings.GetInstance()
|
|
|
@ -147,17 +149,19 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
leastLoadStrategy := NewLeastLoadStrategy(s)
|
|
|
|
leastLoadStrategy := NewLeastLoadStrategy(s)
|
|
|
|
return &Balancer{
|
|
|
|
return &Balancer{
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
ohm: ohm, fallbackTag: br.FallbackTag,
|
|
|
|
ohm: ohm,
|
|
|
|
strategy: leastLoadStrategy,
|
|
|
|
fallbackTag: br.FallbackTag,
|
|
|
|
|
|
|
|
strategy: leastLoadStrategy,
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
case "random":
|
|
|
|
case "random":
|
|
|
|
fallthrough
|
|
|
|
fallthrough
|
|
|
|
case "":
|
|
|
|
case "":
|
|
|
|
return &Balancer{
|
|
|
|
return &Balancer{
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
selectors: br.OutboundSelector,
|
|
|
|
ohm: ohm, fallbackTag: br.FallbackTag,
|
|
|
|
ohm: ohm,
|
|
|
|
strategy: &RandomStrategy{},
|
|
|
|
fallbackTag: br.FallbackTag,
|
|
|
|
|
|
|
|
strategy: &RandomStrategy{},
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return nil, newError("unrecognized balancer type")
|
|
|
|
return nil, newError("unrecognized balancer type")
|
|
|
|