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: Add dead lettering max delivery attempts argument #236
Conversation
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
samples/snippets/subscriber_test.py
Outdated
@@ -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 |
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.
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
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 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.
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.
LGTM if Tianzi is happy - I'll merge once she's seen it (ping me when that time comes if needed)
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.
A few nits then LGTM.
samples/snippets/subscriber.py
Outdated
@@ -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 |
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.
"This is the maximum number of delivery attempts allowed for a message before it gets delivered to a dead letter topic."
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.
nit: I think you still forgot the cross out "an" in "This is an the"
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.
Thank you for pointing that out!
samples/snippets/subscriber.py
Outdated
# 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" |
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.
Ditto.
Add optional max_delivery_attempts argument to sample code to more closely resemble Cloud Pub/Sub behavior.
Fixes #235 🦕