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

Method useDefaultPickIfPossible

balancer/rls/picker.go:231–250  ·  view source on GitHub ↗

useDefaultPickIfPossible is a helper method which delegates to the default target if one is configured, or fails the pick with the given error. Returns a function to be invoked to record metrics.

(info balancer.PickInfo, errOnNoDefault error)

Source from the content-addressed store, hash-verified

229// target if one is configured, or fails the pick with the given error. Returns
230// a function to be invoked to record metrics.
231func (p *rlsPicker) useDefaultPickIfPossible(info balancer.PickInfo, errOnNoDefault error) (balancer.PickResult, func(), error) {
232 customLabel := estats.CustomLabelFromContext(info.Ctx)
233
234 if p.defaultPolicy != nil {
235 state := (*balancer.State)(atomic.LoadPointer(&p.defaultPolicy.state))
236 res, err := state.Picker.Pick(info)
237 pr := errToPickResult(err)
238 return res, func() {
239 if pr == "queue" {
240 // Don't record metrics for queued Picks.
241 return
242 }
243 defaultTargetPicksMetric.Record(p.metricsRecorder, 1, p.grpcTarget, p.rlsServerTarget, p.defaultPolicy.target, pr, customLabel)
244 }, err
245 }
246
247 return balancer.PickResult{}, func() {
248 failedPicksMetric.Record(p.metricsRecorder, 1, p.grpcTarget, p.rlsServerTarget, customLabel)
249 }, errOnNoDefault
250}
251
252// sendRouteLookupRequestLocked adds an entry to the pending request map and
253// sends out an RLS request using the passed in arguments. Returns a value

Callers 1

PickMethod · 0.95

Calls 3

errToPickResultFunction · 0.85
PickMethod · 0.65
RecordMethod · 0.45

Tested by

no test coverage detected