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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add dead lettering max delivery attempts argument #236

Merged
merged 7 commits into from Nov 16, 2020

Conversation

danavaziri-ga
Copy link
Contributor

Add optional max_delivery_attempts argument to sample code to more closely resemble Cloud Pub/Sub behavior.

Fixes #235 馃

Add functionality so users could set max_delivery_attempts while creating or updating a subscription with dead lettering enabled instead of it's value being set to an arbitrary number.
Make the argument optional and set the value to 5 if the user doesn't set it just like Cloud Pub/Sub does.
鈥 with dead lettering calls

Added max delivery attempts parameter to calls to update and create subscriber to match the methods in subscriber.py
@danavaziri-ga danavaziri-ga requested a review from a team as a code owner November 11, 2020 15:40
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Nov 11, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 11, 2020
@danavaziri-ga danavaziri-ga changed the title Patch 1 Add dead lettering max delivery attempts argument Nov 12, 2020
@@ -208,7 +208,7 @@ def test_create_subscription_with_dead_letter_policy(
pass

subscriber.create_subscription_with_dead_letter_topic(
PROJECT_ID, TOPIC, SUBSCRIPTION_DLQ, DEAD_LETTER_TOPIC
PROJECT_ID, TOPIC, SUBSCRIPTION_DLQ, DEAD_LETTER_TOPIC, 10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for this line and line 222

  • What are the values 10 and 20? Why did we choose them to be 10 and 20 and not whatever the default is?
  • If we do need to pass them and not use the default, please use a constant (or two if you want to have the separate values 10&20) like the other arguments passed in the tests - it makes for easier maintenance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed this in a seperate commit 7ad3b6a.

I added two constants one for the default value and one for the updated one. We could call create subscription with the default value, which is what my new commit does. However, the update subscription call should be called with a new value because we are testing to see if max_delivery_attempts changes after the call.

@danavaziri-ga danavaziri-ga changed the title Add dead lettering max delivery attempts argument feat: Add dead lettering max delivery attempts argument Nov 13, 2020
@leahecole leahecole added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2020
Copy link

@leahecole leahecole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if Tianzi is happy - I'll merge once she's seen it (ping me when that time comes if needed)

Copy link
Contributor

@anguillanneuf anguillanneuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits then LGTM.

@@ -108,6 +109,9 @@ def create_subscription_with_dead_letter_topic(
# TODO(developer): This is an existing dead letter topic that the subscription
# with dead letter policy will forward dead letter messages to.
# dead_letter_topic_id = "your-dead-letter-topic-id"
# TODO(developer): This is an the maximum number of delivery attempts allowed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This is the maximum number of delivery attempts allowed for a message before it gets delivered to a dead letter topic."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think you still forgot the cross out "an" in "This is an the"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing that out!

samples/snippets/subscriber.py Outdated Show resolved Hide resolved
Comment on lines 285 to 287
# TODO(developer): This is an the maximum number of delivery attempts allowed
# before a message gets dead lettered.
# max_delivery_attempts = "your-max-delivery-attempts"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@danavaziri-ga danavaziri-ga added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2020
@leahecole leahecole merged commit 7687ae5 into googleapis:master Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add optional argument for max delivery attempts when creating or updating subscription with dead lettering
4 participants