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

fix: use retry_async instead of retry in async client #1030

Merged
merged 5 commits into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 24 additions & 25 deletions google/pubsub_v1/services/publisher/async_client.py
Expand Up @@ -33,15 +33,14 @@
from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import timeout as timeouts # type: ignore
from google.api_core import retry_async as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
Expand Down Expand Up @@ -274,7 +273,7 @@ async def sample_create_topic():
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -306,7 +305,7 @@ async def sample_create_topic():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.create_topic,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -398,7 +397,7 @@ async def sample_update_topic():
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -432,7 +431,7 @@ async def sample_update_topic():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_topic,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -519,7 +518,7 @@ async def sample_publish():
This corresponds to the ``messages`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -553,7 +552,7 @@ async def sample_publish():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.publish,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=4.0,
Expand Down Expand Up @@ -636,7 +635,7 @@ async def sample_get_topic():
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -668,7 +667,7 @@ async def sample_get_topic():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_topic,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -748,7 +747,7 @@ async def sample_list_topics():
This corresponds to the ``project`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -784,7 +783,7 @@ async def sample_list_topics():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_topics,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -875,7 +874,7 @@ async def sample_list_topic_subscriptions():
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -911,7 +910,7 @@ async def sample_list_topic_subscriptions():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_topic_subscriptions,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -1006,7 +1005,7 @@ async def sample_list_topic_snapshots():
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -1042,7 +1041,7 @@ async def sample_list_topic_snapshots():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_topic_snapshots,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -1132,7 +1131,7 @@ async def sample_delete_topic():
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -1160,7 +1159,7 @@ async def sample_delete_topic():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_topic,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -1231,7 +1230,7 @@ async def sample_detach_subscription():
request (Optional[Union[google.pubsub_v1.types.DetachSubscriptionRequest, dict]]):
The request object. Request for the DetachSubscription
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand All @@ -1251,7 +1250,7 @@ async def sample_detach_subscription():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.detach_subscription,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -1299,7 +1298,7 @@ async def set_iam_policy(
request (:class:`~.policy_pb2.SetIamPolicyRequest`):
The request object. Request message for `SetIamPolicy`
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -1420,7 +1419,7 @@ async def get_iam_policy(
request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
The request object. Request message for `GetIamPolicy`
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down Expand Up @@ -1543,7 +1542,7 @@ async def test_iam_permissions(
request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
The request object. Request message for
`TestIamPermissions` method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (TimeoutType):
The timeout for this request.
Expand Down