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)
| 229 | // target if one is configured, or fails the pick with the given error. Returns |
| 230 | // a function to be invoked to record metrics. |
| 231 | func (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 |
no test coverage detected