newPowerOfRandomNChoices selects N random backends and picks the one with less outstanding requests.
([]string)
| 233 | |
| 234 | // newPowerOfRandomNChoices selects N random backends and picks the one with less outstanding requests. |
| 235 | func newPowerOfRandomNChoices([]string) routing.LBAlgorithm { |
| 236 | return &powerOfRandomNChoices{ |
| 237 | rnd: rand.New(rand.NewPCG(uint64(time.Now().UnixNano()), 0)), // #nosec |
| 238 | numberOfChoices: powerOfRandomNChoicesDefaultN, |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Apply implements routing.LBAlgorithm with power of random N choices algorithm. |
| 243 | func (p *powerOfRandomNChoices) Apply(ctx *routing.LBContext) routing.LBEndpoint { |