| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This is looking good. I only reviewed the sync file and not the tests yet; I'll pick this back up tomorrow, but feel free to start responding to the comments here (or wait if you prefer; all good).
Sorry, something went wrong.
| else: | ||
| # Use grpc.compute_engine_channel_credentials in order to support Direct Path. | ||
| # See https://grpc.github.io/grpc/python/grpc.html#grpc.compute_engine_channel_credentials | ||
| # TODO(b/323073050): Although `grpc.compute_engine_channel_credentials` |
There was a problem hiding this comment.
Since this is public code, I would prefer to a public (GitHub) issue in this TODO.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e9199a0
Sorry, something went wrong.
| attempt_direct_path (Optional[bool]): If set, Direct Path will be attempted when | ||
| the request is made. Direct Path provides a proxyless connection which | ||
| increases the available throughput, reduces latency, and increases | ||
| reliability. Outside of GCE, the direct path request may fallback |
There was a problem hiding this comment.
Do we need to spell out what GCE stands for in public docs? Not everyone looking at this file may be using GCE.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e7e3cf7
Sorry, something went wrong.
| If a `ServiceUnavailable` response is received when the request is sent, it is | ||
| recommended that the client repeat the request with `attempt_direct_path` set to `False` | ||
| as the Service may not support Direct Path. Using `ssl_credentials` with `attempt_direct_path` | ||
| set to `True` will result in `ValueError` as it is not yet supported. |
There was a problem hiding this comment.
| set to `True` will result in `ValueError` as it is not yet supported. | |
| set to `True` will result in `ValueError` as this combination is not yet supported. |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e7e3cf7
Sorry, something went wrong.
| attempt_direct_path (Optional[bool]): If set, Direct Path will be attempted when | ||
| the request is made. Direct Path provides a proxyless connection which | ||
| increases the available throughput, reduces latency, and increases | ||
| reliability. Outside of GCE, the direct path request may fallback | ||
| to DNS if this is configured by the Service. This argument should only | ||
| be set in a GCE environment and for Services that are known to support Direct Path. | ||
| If a `ServiceUnavailable` response is received when the request is sent, it is | ||
| recommended that the client repeat the request with `attempt_direct_path` set to `False` | ||
| as the Service may not support Direct Path. Using `ssl_credentials` with `attempt_direct_path` | ||
| set to `True` will result in `ValueError` as it is not yet supported. |
There was a problem hiding this comment.
"Should only be set in a GCE environment" is confusing in light of "Outside of GCE, the request may fall back". Clarify. I suspect you mean something like this:
| attempt_direct_path (Optional[bool]): If set, Direct Path will be attempted when | |
| the request is made. Direct Path provides a proxyless connection which | |
| increases the available throughput, reduces latency, and increases | |
| reliability. Outside of GCE, the direct path request may fallback | |
| to DNS if this is configured by the Service. This argument should only | |
| be set in a GCE environment and for Services that are known to support Direct Path. | |
| If a `ServiceUnavailable` response is received when the request is sent, it is | |
| recommended that the client repeat the request with `attempt_direct_path` set to `False` | |
| as the Service may not support Direct Path. Using `ssl_credentials` with `attempt_direct_path` | |
| set to `True` will result in `ValueError` as it is not yet supported. | |
| attempt_direct_path (Optional[bool]): If set, Direct Path will be attempted when | |
| the request is made. Direct Path is only available within a Google Compute | |
| Engine environment and provides a proxyless connection which increases the | |
| available throughput, reduces latency, and increases reliability. | |
| - This argument should only | |
| be set in a GCE environment and for Services that are known to support Direct | |
| Path. | |
| - If this argument is set outside of GCE, then this request will fail | |
| unless the back-end service happens to have configured fall-back to DNS. | |
| - If the request causes a `ServiceUnavailable` response, we | |
| recommend that the client repeat the request with `attempt_direct_path` set to | |
| `False` as the Service may not support Direct Path. | |
| - Using `ssl_credentials` with `attempt_direct_path` | |
| set to `True` will result in `ValueError` as this combination is not yet | |
| supported. |
(And similarly for the async version)
WDYT?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e7e3cf7
Sorry, something went wrong.
| attempt_direct_path (Optional[bool]): If set, Direct Path will be attempted when | ||
| the request is made. Direct Path provides a proxyless connection which | ||
| increases the available throughput, reduces latency, and increases | ||
| reliability. Outside of GCE, the direct path request may fallback |
There was a problem hiding this comment.
| reliability. Outside of GCE, the direct path request may fallback | |
| reliability. Outside of GCE, the direct path request may fall back |
but see comment below
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e7e3cf7
Sorry, something went wrong.
| target (str): The target service address which is converted into a format compatible with Direct Path. | ||
| If the target contains `dns:///` or does not have contain `:///`, the target will be converted in | ||
| a format compatible with Direct Path, otherwise the original target will be returned. |
There was a problem hiding this comment.
| target (str): The target service address which is converted into a format compatible with Direct Path. | |
| If the target contains `dns:///` or does not have contain `:///`, the target will be converted in | |
| a format compatible with Direct Path, otherwise the original target will be returned. | |
| target (str): The target service address which is converted into a format compatible with Direct Path. | |
| If the target contains `dns:///` or does not contain `:///`, the target will be converted in | |
| a format compatible with Direct Path; otherwise the original target will be returned. |
So the idea is that a :/// (except for dns:///) already denotes Direct Path, so no action is needed, correct? It might be good to be explicit about this assumption.
Sorry, something went wrong.
There was a problem hiding this comment.
Done in 44d5845
Sorry, something went wrong.
| a format compatible with Direct Path, otherwise the original target will be returned. | ||
| """ | ||
|
|
||
| dns_prefix = "dns:///" |
There was a problem hiding this comment.
It might be helpful to clarify in a comment what the dns_prefix means, which I take it is to be explicit about an endpoint living in the Internet (ie outside GCP).
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in e6ea7ec
Sorry, something went wrong.
| default_scopes=None, | ||
| default_host=None, | ||
| compression=None, | ||
| attempt_direct_path: Optional[bool] = None, |
There was a problem hiding this comment.
| attempt_direct_path: Optional[bool] = None, | |
| attempt_direct_path: Optional[bool] = False, |
Since it's meant to be a Boolean, might as well.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in 0f3a0e4
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM! Nothing blocking, but I think some of my suggestions can make things tighter/clearer.
Sorry, something went wrong.
| # If `ssl_credentials` is set and `attempt_direct_path` is set to `True`, | ||
| # raise ValueError as this is not yet supported. | ||
| # See https://github.com/googleapis/python-api-core/issues/590 | ||
| if ssl_credentials is not None and attempt_direct_path: |
There was a problem hiding this comment.
Could we simplify to just this?:
| if ssl_credentials is not None and attempt_direct_path: | |
| if ssl_credentials and attempt_direct_path: |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in 60b8acb
Sorry, something went wrong.
| "Compression argument is being ignored for grpc_gcp.secure_channel creation." | ||
| ) | ||
| if attempt_direct_path: | ||
| warnings.warn( |
There was a problem hiding this comment.
For consistency, the _LOGGER.debug in the previous lines should probably also become a warnings.warn
Sorry, something went wrong.
Sorry, something went wrong.
| Given a target, return a modified version which is compatible with Direct Path. | ||
|
|
||
| Args: | ||
| target (str): The target service address in the format 'hostname:port', 'dns://hostname' or other |
There was a problem hiding this comment.
| target (str): The target service address in the format 'hostname:port', 'dns://hostname' or other | |
| target (str): The target service address in the format 'hostname[:port]', 'dns://hostname[:port]' or other |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in af3a21b
Sorry, something went wrong.
|
|
||
| Args: | ||
| target (str): The target service address in the format 'hostname:port', 'dns://hostname' or other | ||
| compatible format. |
There was a problem hiding this comment.
"other compatible format": link to a place that lists compatible formats, or remove this phrase which I think is puzzling by itself.
Sorry, something went wrong.
There was a problem hiding this comment.
Removed in af3a21b
Sorry, something went wrong.
| direct_path_prefix = ":///" | ||
| if direct_path_prefix not in target: |
There was a problem hiding this comment.
| direct_path_prefix = ":///" | |
| if direct_path_prefix not in target: | |
| direct_path_separator = ":///" | |
| if direct_path_separator not in target: |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in c0052e6
Sorry, something went wrong.
| ) | ||
|
|
||
|
|
||
| def _modify_target_for_direct_path(target: str) -> str: |
There was a problem hiding this comment.
Q: In general, an API endpoint could depend on the URL path and not just the host+port. Is this true of Google APIs? If so, where do we deal with the path part of the URI? (I realize these functions specify only host+port as inputs, so it's clear what they expect and they're doing the right thing, but I was wondering about this more general question.)
Sorry, something went wrong.
There was a problem hiding this comment.
If so, where do we deal with the path part of the URI?
I believe this is part of the transcode method
Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here,
python-api-core/google/api_core/path_template.py
Lines 250 to 259 in b72929f
Sorry, something went wrong.
| import functools | ||
|
|
||
| from typing import Generic, Iterator, AsyncGenerator, TypeVar | ||
| from typing import AsyncGenerator, Generic, Iterator, Optional, TypeVar |
There was a problem hiding this comment.
General notes:
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for opening that issue! I also made changes to the async code based on the sync code feedback.
Sorry, something went wrong.
| def test_create_channel_implicit(grpc_secure_channel, default, composite_creds_call): | ||
| def test_create_channel_implicit( | ||
| grpc_secure_channel, | ||
| default, |
There was a problem hiding this comment.
default is too generic a name. I assume this is meant to take the google.auth.default you have patched in the decorators. Is there any way this parameter name could be made more descriptive (like auth-default, say), or does @mock preclude that?
(I realize this was pre-existing, so no need to spend too much time on this. But if it's easy...)
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed in d63402e
Sorry, something went wrong.
|
|
||
|
|
||
| @mock.patch("grpc.composite_channel_credentials") | ||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
Would it be worth making this test function take a target parameter, and then parametrizing it as we do for test_create_channel_implicit_with_default_host below? target seems to be used the same way in both places, and this would allow us to check here the dns:/// and another-c2p:/// cases you parametrize below.
Sorry, something went wrong.
There was a problem hiding this comment.
Done in 396d8fa
Sorry, something went wrong.
|
|
||
|
|
||
| @mock.patch("grpc.composite_channel_credentials") | ||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
Same comments as in sync version apply here.
Sorry, something went wrong.
There was a problem hiding this comment.
Done in 396d8fa
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #482
b/267782870