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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pubsub): Add pubsub_dead_letter_remove #700

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pubsub/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

source "https://rubygems.org"

gem "google-cloud-pubsub"
gem "google-cloud-pubsub", "~> 2.2"
Copy link
Member Author

Choose a reason for hiding this comment

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

@TheRoyalTnetennba Should I not specify a version constraint for google-cloud-pubsub in the Gemfile? (For the example added in this PR, version 2.2 or above is required.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is good to specify version constraints where required.

gem "sinatra"

group :test do
Expand Down
4 changes: 2 additions & 2 deletions pubsub/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GEM
google-cloud-env (1.4.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.0.1)
google-cloud-pubsub (2.1.0)
google-cloud-pubsub (2.2.0)
concurrent-ruby (~> 1.1)
google-cloud-core (~> 1.5)
google-cloud-pubsub-v1 (~> 0.0)
Expand Down Expand Up @@ -88,7 +88,7 @@ PLATFORMS
ruby

DEPENDENCIES
google-cloud-pubsub
google-cloud-pubsub (~> 2.2)
minitest (~> 5.13)
minitest-focus (~> 1.1)
minitest-hooks (~> 1.5)
Expand Down
2 changes: 1 addition & 1 deletion pubsub/acceptance/subscriptions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

it "supports pubsub_subscriber_sync_pull_with_lease" do
@topic.publish "This is a test message."
sleep 1
sleep 10

# # pubsub_subscriber_sync_pull_with_lease
expect_with_retry "pubsub_subscriber_sync_pull_with_lease" do
Expand Down
8 changes: 8 additions & 0 deletions pubsub/acceptance/topics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@
assert_includes out, "Delivery Attempt: 1"
end

# pubsub_dead_letter_remove
assert_output "Removed dead letter topic from #{subscription_name} subscription.\n" do
dead_letter_remove subscription_name: subscription_name
end
@subscription.reload!
refute @subscription.dead_letter_topic
refute @subscription.dead_letter_max_delivery_attempts

ensure
@dead_letter_topic.delete
end
Expand Down
16 changes: 16 additions & 0 deletions pubsub/subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ def dead_letter_update_subscription subscription_name:
# [END pubsub_dead_letter_update_subscription]
end

def dead_letter_remove subscription_name:
# [START pubsub_dead_letter_remove]
# subscription_name = "Your Pubsub subscription name"
require "google/cloud/pubsub"

pubsub = Google::Cloud::Pubsub.new

subscription = pubsub.subscription subscription_name
subscription.remove_dead_letter_policy
puts "Removed dead letter topic from #{subscription_name} subscription."
# [END pubsub_dead_letter_remove]
end

def listen_for_messages subscription_name:
# [START pubsub_subscriber_async_pull]
# [START pubsub_quickstart_subscriber]
Expand Down Expand Up @@ -359,6 +372,8 @@ def subscriber_sync_pull_with_lease subscription_name:
test_subscription_permissions subscription_name: ARGV.shift
when "dead_letter_update_subscription"
dead_letter_update_subscription subscription_name: ARGV.shift
when "dead_letter_remove"
dead_letter_remove subscription_name: ARGV.shift
when "listen_for_messages"
listen_for_messages subscription_name: ARGV.shift
when "listen_for_messages_with_custom_attributes"
Expand Down Expand Up @@ -388,6 +403,7 @@ def subscriber_sync_pull_with_lease subscription_name:
set_subscription_policy <subscription_name> Set policies of a subscription
test_subscription_permissions <subscription_name> Test policies of a subscription
dead_letter_update_subscription <subscription_name> Update a subscription's dead letter policy
dead_letter_remove <subscription_name> Delete a subscription's dead letter policy
listen_for_messages <subscription_name> Listen for messages
listen_for_messages_with_custom_attributes <subscription_name> Listen for messages with custom attributes
pull_messages <subscription_name> Pull messages
Expand Down