MCPcopy Index your code
hub / github.com/dropbox/godropbox / sortInstances

Method sortInstances

net2/http2/load_balanced_pool.go:155–171  ·  view source on GitHub ↗
(instances instancePoolSlice, hashes []uint32)

Source from the content-addressed store, hash-verified

153}
154
155func (pool *LoadBalancedPool) sortInstances(instances instancePoolSlice, hashes []uint32) {
156 switch pool.strategy {
157 case LBRoundRobin:
158 sort.Sort(shuffleSortHelper{shuffleSeed: pool.shuffleSeed, instances: instances})
159 // In ShuffledFixed strategy, InstanceList is a deterministically shuffled list.
160 case LBShuffledFixed:
161 sort.Sort(shuffleSortHelper{shuffleSeed: pool.shuffleSeed, instances: instances})
162 // In SortedFixed strategy, InstanceList is a sorted list, sorted by instanceId.
163 case LBSortedFixed:
164 sort.Sort(instances)
165 // In LBConsistentHashing strategy, InstanceList is sorted based on consistent-hashing
166 case LBConsistentHashing:
167 hashHelper := consistentHashSortHelper{
168 Instances: instances, Hashes: hashes}
169 sort.Sort(hashHelper)
170 }
171}
172
173func (pool *LoadBalancedPool) Update(instanceInfos []LBPoolInstanceInfo) {
174

Callers 1

UpdateMethod · 0.95

Calls 1

SortMethod · 0.45

Tested by

no test coverage detected