MCPcopy Create free account
hub / github.com/zalando/skipper / chooseConsistentHashEndpoint

Method chooseConsistentHashEndpoint

loadbalancer/algorithm.go:212–226  ·  view source on GitHub ↗
(ctx *routing.LBContext)

Source from the content-addressed store, hash-verified

210}
211
212func (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
228type powerOfRandomNChoices struct {
229 mu sync.Mutex

Callers 1

ApplyMethod · 0.95

Calls 3

searchMethod · 0.95
boundedLoadSearchMethod · 0.95
StringMethod · 0.65

Tested by

no test coverage detected