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

Method Pick

interop/orcalb.go:201–224  ·  view source on GitHub ↗
(info balancer.PickInfo)

Source from the content-addressed store, hash-verified

199}
200
201func (p *orcaPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
202 res, err := p.childPicker.Pick(info)
203 if err != nil {
204 return res, err
205 }
206
207 p.oobState.mu.Lock()
208 lr := p.oobState.reports[res.SubConn]
209 p.oobState.mu.Unlock()
210
211 origDone := res.Done
212 res.Done = func(di balancer.DoneInfo) {
213 perRPCLR, _ := di.ServerLoad.(*v3orcapb.OrcaLoadReport)
214 if perRPCLR != nil && (perRPCLR.CpuUtilization != 0 || perRPCLR.MemUtilization != 0 || len(perRPCLR.Utilization) > 0 || len(perRPCLR.RequestCost) > 0) {
215 setContextCMR(info.Ctx, perRPCLR)
216 } else if lr != nil {
217 setContextCMR(info.Ctx, lr)
218 }
219 if origDone != nil {
220 origDone(di)
221 }
222 }
223 return res, nil
224}
225
226func setContextCMR(ctx context.Context, lr *v3orcapb.OrcaLoadReport) {
227 if r := orcaResultFromContext(ctx); r != nil {

Callers

nothing calls this directly

Calls 4

setContextCMRFunction · 0.85
PickMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected