Skip to content

Commit

Permalink
Save a request by hitting out to check FIFO
Browse files Browse the repository at this point in the history
  • Loading branch information
maschwenk committed Jul 20, 2017
1 parent bd3d591 commit 711e607
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/shoryuken/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,25 @@ def fifo?

private

def parse_queue_url_params(name_or_url)
if name_or_url.start_with?('https://sqs.')
*_, account_id, queue_name = URI.parse(name_or_url).path.split('/')
{
queue_name: queue_name,
queue_owner_aws_account_id: account_id
}
else
{ queue_name: name_or_url }
end
def set_by_name(name)
self.name = name
self.url = client.get_queue_url(queue_name: name).queue_url
end

def set_by_url(url)
self.name = url.split('/').last
self.url = url
end

def set_name_and_url(name_or_url)
queue_url_params = parse_queue_url_params(name_or_url)
self.name = queue_url_params[:queue_name]
self.url = client.get_queue_url(queue_url_params)
if name_or_url.start_with?('https://sqs.')
set_by_url(name_or_url)

# anticipate the fifo? checker for validating the queue URL
return fifo?
end

set_by_name(name_or_url)
rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue => ex
raise ex, "The specified queue #{name_or_url} does not exist."
end
Expand Down

0 comments on commit 711e607

Please sign in to comment.