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

Method lookup

balancer/rls/control_channel.go:197–219  ·  view source on GitHub ↗

lookup starts a RouteLookup RPC in a separate goroutine and returns the results (and error, if any) in the provided callback. The returned boolean indicates whether the request was throttled by the client-side adaptive throttling algorithm in which case the provided callback will not be invoked.

(reqKeys map[string]string, reason rlspb.RouteLookupRequest_Reason, staleHeaders string, cb lookupCallback)

Source from the content-addressed store, hash-verified

195// client-side adaptive throttling algorithm in which case the provided callback
196// will not be invoked.
197func (cc *controlChannel) lookup(reqKeys map[string]string, reason rlspb.RouteLookupRequest_Reason, staleHeaders string, cb lookupCallback) (throttled bool) {
198 if cc.throttler.ShouldThrottle() {
199 cc.logger.Infof("RLS request throttled by client-side adaptive throttling")
200 return true
201 }
202 go func() {
203 req := &rlspb.RouteLookupRequest{
204 TargetType: "grpc",
205 KeyMap: reqKeys,
206 Reason: reason,
207 StaleHeaderData: staleHeaders,
208 }
209 if cc.logger.V(2) {
210 cc.logger.Infof("Sending RLS request %+v", pretty.ToJSON(req))
211 }
212
213 ctx, cancel := context.WithTimeout(context.Background(), cc.rpcTimeout)
214 defer cancel()
215 resp, err := cc.client.RouteLookup(ctx, req)
216 cb(resp.GetTargets(), resp.GetHeaderData(), err)
217 }()
218 return false
219}

Calls 7

ToJSONFunction · 0.92
GetTargetsMethod · 0.80
GetHeaderDataMethod · 0.80
ShouldThrottleMethod · 0.65
InfofMethod · 0.65
VMethod · 0.65
RouteLookupMethod · 0.65