Skip to content

Commit

Permalink
Merge pull request #341 from phstc/fix-339
Browse files Browse the repository at this point in the history
Use `get_queue_url` to get a single queue URL

Fix #339
  • Loading branch information
phstc authored Mar 19, 2017
2 parents 7e002f9 + d3076db commit 544a05b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions bin/cli/sqs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,10 @@ def sqs
@_sqs ||= Aws::SQS::Client.new
end

def find_queue_url(queue_name_prefix)
urls = sqs.list_queues(queue_name_prefix: queue_name_prefix).queue_urls

if urls.size > 1
fail_task "There's more than one queue starting with #{queue_name_prefix}: #{urls.join(', ')}"
end

url = urls.first

fail_task "Queue #{queue_name_prefix} not found" unless url

url
def find_queue_url(queue_name)
sqs.get_queue_url(queue_name: queue_name).queue_url
rescue Aws::SQS::Errors::NonExistentQueue
fail_task "The specified queue #{queue_name} does not exist"
end

def batch_delete(url, messages)
Expand Down

0 comments on commit 544a05b

Please sign in to comment.