X Tutup
Skip to content

Add DEFAULT sentinel for gapic_v1.method#4079

Merged
theacodes merged 2 commits intogoogleapis:masterfrom
theacodes:api-core-method-sentinel
Sep 28, 2017
Merged

Add DEFAULT sentinel for gapic_v1.method#4079
theacodes merged 2 commits intogoogleapis:masterfrom
theacodes:api-core-method-sentinel

Conversation

@theacodes
Copy link
Copy Markdown
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
Copy Markdown
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

_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.

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.

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

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
parthea pushed a commit that referenced this pull request Nov 24, 2025
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

X Tutup