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

@danavaziri-ga danavaziri-ga commented Nov 11, 2020

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 as a code owner Nov 11, 2020
@danavaziri-ga danavaziri-ga requested a review from leahecole Nov 11, 2020
@google-cla google-cla bot added the cla: yes 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

Loading

Copy link
Contributor Author

@danavaziri-ga danavaziri-ga Nov 13, 2020

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.

Loading

@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
Copy link

@leahecole leahecole left a comment

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

Loading

Copy link
Contributor

@anguillanneuf anguillanneuf left a comment

A few nits then LGTM.

Loading

@@ -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

@anguillanneuf anguillanneuf Nov 13, 2020

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."

Loading

Copy link
Contributor

@anguillanneuf anguillanneuf Nov 13, 2020

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"

Loading

Copy link
Contributor Author

@danavaziri-ga danavaziri-ga Nov 13, 2020

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!

Loading

samples/snippets/subscriber.py Outdated Show resolved Hide resolved
Loading
# 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

@anguillanneuf anguillanneuf Nov 13, 2020

Choose a reason for hiding this comment

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

Ditto.

Loading

@anguillanneuf anguillanneuf self-requested a review Nov 13, 2020
@leahecole leahecole merged commit 7687ae5 into googleapis:master Nov 16, 2020
9 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants