(ctx *routing.LBContext)
| 210 | } |
| 211 | |
| 212 | func (ch *consistentHash) chooseConsistentHashEndpoint(ctx *routing.LBContext) int { |
| 213 | key, ok := ctx.Params[ConsistentHashKey].(string) |
| 214 | if !ok { |
| 215 | key = snet.RemoteHost(ctx.Request).String() |
| 216 | } |
| 217 | balanceFactor, ok := ctx.Params[ConsistentHashBalanceFactor].(float64) |
| 218 | var choice int |
| 219 | if !ok { |
| 220 | choice = ch.search(key, ctx) |
| 221 | } else { |
| 222 | choice = ch.boundedLoadSearch(key, balanceFactor, ctx) |
| 223 | } |
| 224 | |
| 225 | return choice |
| 226 | } |
| 227 | |
| 228 | type powerOfRandomNChoices struct { |
| 229 | mu sync.Mutex |
no test coverage detected