| 153 | } |
| 154 | |
| 155 | func (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 | |
| 173 | func (pool *LoadBalancedPool) Update(instanceInfos []LBPoolInstanceInfo) { |
| 174 | |