Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEFAULT sentinel for gapic_v1.method #4079

Merged
merged 2 commits into from
Sep 28, 2017

Conversation

theacodes
Copy link
Contributor

This is needed because the wrapped gapic methods can't discern between "unspecified" and "None" because the gapic clients will always specify retry and timeout, e.g.:

def get_operation(name, retry=None, timeout=None):
     request = operations_pb2.GetOperationRequest(name=name)
     return self._get_operation(request, retry=retry, timeout=timeout)

gapic methods will use this sentinel to indicate unspecified:

def get_operation(name, retry=gapic_v1.method.DEFAULT, timeout=gapic_v1.method.DEFAULT):
     request = operations_pb2.GetOperationRequest(name=name)
     return self._get_operation(request, retry=retry, timeout=timeout)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 28, 2017
Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -33,6 +33,7 @@
_API_CORE_VERSION = pkg_resources.get_distribution('google-cloud-core').version
METRICS_METADATA_KEY = 'x-goog-api-client'
USE_DEFAULT_METADATA = object()
DEFAULT = object()

This comment was marked as spam.

This comment was marked as spam.

@@ -88,12 +89,16 @@ def _determine_timeout(default_timeout, specified_timeout, retry):
Returns:
Optional[Timeout]: The timeout to apply to the method or ``None``.
"""
if specified_timeout is DEFAULT:
specified_timeout = default_timeout

This comment was marked as spam.

This comment was marked as spam.

unusued_sleep):
method = mock.Mock(spec=['__call__'], side_effect=[
exceptions.InternalServerError(None),
42])

This comment was marked as spam.

This comment was marked as spam.

@theacodes theacodes merged commit 95d4e03 into googleapis:master Sep 28, 2017
@theacodes theacodes deleted the api-core-method-sentinel branch September 28, 2017 20:58
@theacodes theacodes mentioned this pull request Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants