MCPcopy
hub / github.com/grpc/grpc-go / pick

Method pick

balancer/ringhash/ring.go:176–184  ·  view source on GitHub ↗

pick does a binary search. It returns the item with smallest index i that r.items[i].hash >= h.

(h uint64)

Source from the content-addressed store, hash-verified

174// pick does a binary search. It returns the item with smallest index i that
175// r.items[i].hash >= h.
176func (r *ring) pick(h uint64) *ringEntry {
177 i := sort.Search(len(r.items), func(i int) bool { return r.items[i].hash >= h })
178 if i == len(r.items) {
179 // If not found, and h is greater than the largest hash, return the
180 // first item.
181 i = 0
182 }
183 return r.items[i]
184}
185
186// next returns the next entry.
187func (r *ring) next(e *ringEntry) *ringEntry {

Callers 8

getTransportMethod · 0.45
TestBlockingPickMethod · 0.45
PickMethod · 0.45
TestRingPickMethod · 0.45

Calls 1

SearchMethod · 0.65