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
wip: Allow retry and timeout settings on the publisher client #239
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
729a5e7
feat: allow retry and timeout settings on publisher client
cguardia a9b5190
build: update generated code and update doc
cguardia 1b8767b
Merge branch 'master' into retry-timeout-settings
cguardia b06d122
Merge branch 'master' into retry-timeout-settings
cguardia File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
from google.api_core import exceptions # type: ignore | ||
from google.api_core import gapic_v1 # type: ignore | ||
from google.api_core import retry as retries # type: ignore | ||
from google.api_core import timeout as timeouts # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a generated file, but I included it in this PR so that it can be seen what the synth changes will do to it. |
||
from google.auth import credentials # type: ignore | ||
from google.auth.transport import mtls # type: ignore | ||
from google.auth.transport.grpc import SslCredentials # type: ignore | ||
|
@@ -363,7 +364,9 @@ def create_topic( | |
*, | ||
name: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pubsub.Topic: | ||
r"""Creates the given topic with the given name. See the `resource | ||
|
@@ -441,7 +444,9 @@ def update_topic( | |
request: pubsub.UpdateTopicRequest = None, | ||
*, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pubsub.Topic: | ||
r"""Updates an existing topic. Note that certain | ||
|
@@ -496,7 +501,9 @@ def publish( | |
topic: str = None, | ||
messages: Sequence[pubsub.PubsubMessage] = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pubsub.PublishResponse: | ||
r"""Adds one or more messages to the topic. Returns ``NOT_FOUND`` if | ||
|
@@ -577,7 +584,9 @@ def get_topic( | |
*, | ||
topic: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pubsub.Topic: | ||
r"""Gets the configuration of a topic. | ||
|
@@ -648,7 +657,9 @@ def list_topics( | |
*, | ||
project: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pagers.ListTopicsPager: | ||
r"""Lists matching topics. | ||
|
@@ -729,7 +740,9 @@ def list_topic_subscriptions( | |
*, | ||
topic: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pagers.ListTopicSubscriptionsPager: | ||
r"""Lists the names of the attached subscriptions on this | ||
|
@@ -813,7 +826,9 @@ def list_topic_snapshots( | |
*, | ||
topic: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pagers.ListTopicSnapshotsPager: | ||
r"""Lists the names of the snapshots on this topic. Snapshots are | ||
|
@@ -901,7 +916,9 @@ def delete_topic( | |
*, | ||
topic: str = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> None: | ||
r"""Deletes the topic with the given name. Returns ``NOT_FOUND`` if | ||
|
@@ -972,7 +989,9 @@ def detach_subscription( | |
request: pubsub.DetachSubscriptionRequest = None, | ||
*, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> pubsub.DetachSubscriptionResponse: | ||
r"""Detaches a subscription from this topic. All messages retained | ||
|
@@ -1031,7 +1050,9 @@ def set_iam_policy( | |
request: iam_policy.SetIamPolicyRequest = None, | ||
*, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> policy.Policy: | ||
r"""Sets the IAM access control policy on the specified | ||
|
@@ -1141,7 +1162,9 @@ def get_iam_policy( | |
request: iam_policy.GetIamPolicyRequest = None, | ||
*, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> policy.Policy: | ||
r"""Gets the IAM access control policy for a function. | ||
|
@@ -1252,7 +1275,9 @@ def test_iam_permissions( | |
request: iam_policy.TestIamPermissionsRequest = None, | ||
*, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
timeout: Union[ | ||
timeouts.ConstantTimeout, timeouts.ExponentialTimeout | ||
] = gapic_v1.method.DEFAULT, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> iam_policy.TestIamPermissionsResponse: | ||
r"""Tests the specified permissions against the IAM access control | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If retry and timeout are added to PublisherOptions, then there's no need to add these parameters here, yes? The user passes them in using the **attrs, like here:
python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Line 101 in b06d122
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somebody might want to override these default options for a few particular
publish()
calls?I'd say we keep these two arguments for flexibility, as well as for consistency with other Publisher methods. Besides, the
publish()
method signature already includes theretry
parameter and thus shouldn't be removed, and it makes more sense to retaintimeout
with it.