This repository was archived by the owner on Mar 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
feat: support customizable retry and timeout settings on the publisher client #299
Merged
Merged
Changes from 15 commits
Commits
Show all changes
19 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 54a1fd6
Merge branch 'master' into iss-222
plamut 12f2140
Propagate publish timeout to the RPC call
plamut 240f992
test publisher client
plamut 272ccdc
Fix timeout parameter type in docstrings
plamut a0a1fcb
Apply timeout changes to async publisher client
plamut 2d0046c
Merge branch 'master' into iss-222
plamut 3ad5779
Merge branch 'master' into iss-222
plamut ce8daea
Introduce TimeoutType type alias
plamut 2adaba1
Update PublisherOptions docs
plamut 072d636
Use type alias for timeout in upgrading guide
plamut 44d94b8
Widen timeout types in generated publisher clients
plamut d1f0294
Use TimeoutType in handwritten code
plamut 05b556e
Remove redundant backslash
plamut 762b129
Use DEFAULT as a defualt timeout in base sequencer
plamut b7939d1
Do not accept plain None as a valid timeout
plamut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,10 +18,13 @@ | |
| import enum | ||
| import inspect | ||
| import sys | ||
| from typing import Union | ||
|
|
||
| import proto | ||
|
|
||
| from google.api import http_pb2 | ||
| import google.api_core | ||
| from google.api_core import gapic_v1 | ||
| from google.iam.v1 import iam_policy_pb2 | ||
| from google.iam.v1 import policy_pb2 | ||
| from google.iam.v1.logging import audit_data_pb2 | ||
|
|
@@ -36,6 +39,16 @@ | |
| from google.pubsub_v1.types import pubsub as pubsub_gapic_types | ||
|
|
||
|
|
||
| TimeoutType = Union[ | ||
| None, | ||
|
Contributor
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. Did we mean to add This feels like an unintentional change. We didn't accept If we want to accept to treat
Contributor
Author
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. Actually we did, even though the argument description says otherwise. But the generated code actually used |
||
| int, | ||
| float, | ||
| google.api_core.timeout.ConstantTimeout, | ||
| google.api_core.timeout.ExponentialTimeout, | ||
| ] | ||
| """The type of the timeout parameter of publisher client methods.""" | ||
|
|
||
|
|
||
| # Define the default values for batching. | ||
| # | ||
| # This class is used when creating a publisher or subscriber client, and | ||
|
|
@@ -98,11 +111,13 @@ class LimitExceededBehavior(str, enum.Enum): | |
| # This class is used when creating a publisher client to pass in options | ||
| # to enable/disable features. | ||
| PublisherOptions = collections.namedtuple( | ||
| "PublisherConfig", ["enable_message_ordering", "flow_control"] | ||
| "PublisherOptions", ["enable_message_ordering", "flow_control", "retry", "timeout"] | ||
| ) | ||
| PublisherOptions.__new__.__defaults__ = ( | ||
| False, # enable_message_ordering: False | ||
| PublishFlowControl(), # default flow control settings | ||
| gapic_v1.method.DEFAULT, # use default api_core value for retry | ||
| gapic_v1.method.DEFAULT, # use default api_core value for timeout | ||
| ) | ||
| PublisherOptions.__doc__ = "The options for the publisher client." | ||
| PublisherOptions.enable_message_ordering.__doc__ = ( | ||
|
|
@@ -112,6 +127,14 @@ class LimitExceededBehavior(str, enum.Enum): | |
| "Flow control settings for message publishing by the client. By default " | ||
| "the publisher client does not do any throttling." | ||
| ) | ||
| PublisherOptions.retry.__doc__ = ( | ||
| "Retry settings for message publishing by the client. This should be " | ||
| "an instance of :class:`google.api_core.retry.Retry`." | ||
| ) | ||
| PublisherOptions.timeout.__doc__ = ( | ||
| "Timeout settings for message publishing by the client. It should be compatible " | ||
| "with :class:`~.pubsub_v1.types.TimeoutType`." | ||
| ) | ||
|
plamut marked this conversation as resolved.
|
||
|
|
||
| # Define the type class and default values for flow control settings. | ||
| # | ||
|
|
@@ -194,6 +217,7 @@ def _get_protobuf_messages(module): | |
| _local_modules = [pubsub_gapic_types] | ||
|
|
||
| names = [ | ||
| "TimeoutType", | ||
| "BatchSettings", | ||
| "LimitExceededBehavior", | ||
| "PublishFlowControl", | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.