github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/app/router/strategy_random.go (about) 1 package router 2 3 import ( 4 "github.com/xmplusdev/xmcore/common/dice" 5 ) 6 7 // RandomStrategy represents a random balancing strategy 8 type RandomStrategy struct{} 9 10 func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string { 11 return strings 12 } 13 14 func (s *RandomStrategy) PickOutbound(candidates []string) string { 15 count := len(candidates) 16 if count == 0 { 17 // goes to fallbackTag 18 return "" 19 } 20 return candidates[dice.Roll(count)] 21 }