Description
Is your feature request related to a problem? Please describe.
The current behavior for grpc does not utilize DirectPath. DirectPath leads to improved latency for request originating from GCE VMs and gcloud storage
relies on this feature.
Describe the solution you'd like
Two changes are needed:
- Replace:
with:
if compute_engine_channel_credentials_requested:
return grpc.compute_engine_channel_credentials(google_auth_credentials)
else:
grpc.composite_channel_credentials(ssl_credentials, google_auth_credentials)
where, compute_engine_channel_credentials_requested will be a bool
passed to the create_channel
call. Alternatively, it can rely on the env variable like it's done for other languages
- Add the
google-c2p
resolver. This can be similar to how other languages e.g. go handles it https://github.com/googleapis/google-api-go-client/blob/8d8f0a70d0bd6ba4daaa08370d1420f759ff7f9d/transport/grpc/dial.go#L182
Describe alternatives you've considered
For #2
above, we can potentially update the GAPIC client generator to create the host name with google-c2p:///
prefixed. But I think given that all other languages are handling it in the middleware, it is appropriate to make this change in this library.
Additional context
There is an internal bug related to this, but I'm not sure if I link it on a public repo.