(endpoints []string, hashesPerEndpoint int)
| 113 | } |
| 114 | |
| 115 | func 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 | |
| 129 | func newConsistentHash(endpoints []string) routing.LBAlgorithm { |
| 130 | return newConsistentHashInternal(endpoints, 100) |
searching dependent graphs…