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

Function newConsistentHashInternal

loadbalancer/algorithm.go:115–127  ·  view source on GitHub ↗
(endpoints []string, hashesPerEndpoint int)

Source from the content-addressed store, hash-verified

113}
114
115func newConsistentHashInternal(endpoints []string, hashesPerEndpoint int) routing.LBAlgorithm {
116 ch := &consistentHash{
117 hashRing: make([]endpointHash, hashesPerEndpoint*len(endpoints)),
118 }
119 for i, ep := range endpoints {
120 endpointStartIndex := hashesPerEndpoint * i
121 for j := 0; j < hashesPerEndpoint; j++ {
122 ch.hashRing[endpointStartIndex+j] = endpointHash{i, hash(fmt.Sprintf("%s-%d", ep, j))}
123 }
124 }
125 sort.Sort(ch)
126 return ch
127}
128
129func newConsistentHash(endpoints []string) routing.LBAlgorithm {
130 return newConsistentHashInternal(endpoints, 100)

Callers 2

measureStdDevFunction · 0.85
newConsistentHashFunction · 0.85

Calls 1

hashFunction · 0.70

Tested by 1

measureStdDevFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…