-
Notifications
You must be signed in to change notification settings - Fork 207
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
feat: support customizable retry and timeout settings on the publisher client #299
Conversation
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
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.
I think the type UNION should admit floats and ints.
I also think the union should be defined once and reused.
There's an obscene amount of repetition in this package. It was already there, but may be can not add to it. :)
google/cloud/pubsub_v1/types.py
Outdated
@@ -37,6 +39,16 @@ | |||
from google.pubsub_v1.types import pubsub as pubsub_gapic_types | |||
|
|||
|
|||
TimeoutType = Union[ | |||
None, |
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.
Did we mean to add None
? Was this my fault?
This feels like an unintentional change. We didn't accept None
before.
If we want to accept None
, then I think we should update
to treat None
like DEFAULT
.
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.
Actually we did, even though the argument description says otherwise. But the generated code actually used None
as a default value for a supposedly float-only argument. :)
@@ -315,6 +313,9 @@ async def update_topic( | |||
), | |||
) | |||
|
|||
if timeout is None or isinstance(timeout, (int, float)): | |||
timeout = timeouts.ConstantTimeout(timeout) |
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.
We shouldn't need this except for the None
case, which is new. I don't think we should accept None
. Apologies if None
came from me.
int
and float
are handled here:
The same comment applies to other places where you added this.
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.
And, of course, not DRY.
@@ -45,18 +47,17 @@ def unpause(self, message): # pragma: NO COVER | |||
|
|||
@staticmethod | |||
@abc.abstractmethod | |||
def publish(self, message, retry=None, timeout=None): # pragma: NO COVER | |||
def publish( | |||
self, message, retry=None, timeout: gapic_types.TimeoutType = None |
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.
Can we use DEFAULT
rather than None
? The implementation defaults to DEFAULT
.
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.
That makes sense, the ABC should be consistent.
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.
Thanks for these changes.
My only complaint is that we added None as a valid timeout, which causes some pain.
@jimfulton I added (not saying that explicitly disabling any timeouts is a good idea, but we already support that automaticlally if we allow instances of |
Flaky samples tests, 500 internal. |
That's fair, but at least you could argue that we should make people work to disable timeouts. BTW, I tried to figure out what the effect of passing In any case, if we want to accept |
I actually don't see a good reason why somebody wanted to potentially block indefinitely, thus I'm fine with removing support for a plain |
Using no timeout is not a good idea, but if one really wants to, they can pass it in as ConstantTimeout(None). As a side effect, the logic of converting a constant into a COnstantTimeout instance can be removed, as this is already handled in api-core for int and float values.
If I read it correctly, a |
* chore: migrate to owl bot * chore: copy files from googleapis-gen 40278112d2922ec917140dcb5cc6d5ef2923aeb2 * chore: run the post processor * pull in synth.py changes from #299 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md * .github/use gcr.io/cloud-devrel-public-resources/owlbot-python post processor image * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md * fix owlbot.py replacement * Copy generated code from googleapis-gen * Work around gapic generator docstring bug * fix: require google-api-core >= 1.26.0 * Work around gapic generator docstring bug * fix(deps): add packaging requirement * revert .coveragerc Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Closes #222.
Supersedes #239.
This PR adds support for API core timeout classes to the publisher class, replacing the previous
float
timeouts.PR checklist: