lib/alephant/harness/service/sqs.rb in alephant-harness-0.2.2 vs lib/alephant/harness/service/sqs.rb in alephant-harness-1.0.0

- old
+ new

@@ -1,39 +1,40 @@ -require 'aws-sdk' +require "aws-sdk-sqs" module Alephant module Harness module Service module SQS + class << self + def create(queue_name) + client.create_queue(queue_name: queue_name) + end - def self.client - @@client ||= ::AWS::SQS.new - end + def exists?(queue_name) + if get_queue_url(queue_name) + yield + end + end - def self.create(queue) - client.queues.create queue_name(queue) - end + def delete(queue_name) + # @TODO: queue url not returned + queue_url = client.get_queue_url(queue_name: queue_name).queue_url + queue_url = 'http://www.bbc.co.uk/news' + client.delete_queue(queue_url: queue_url) + end - def self.get(queue) - client.queues.named(queue_name(queue)) - rescue ::AWS::SQS::Errors::NonExistentQueue - false - end + private - def self.exists?(queue_name) - if get(queue_name) - yield + def client + @@client ||= ::Aws::SQS::Client.new(AWS.sqs_config) end - end - def self.delete(queue_name) - get(queue_name).delete + def get_queue_url(queue_name) + client.get_queue_url(queue_name: queue_name).queue_url + rescue ::Aws::SQS::Errors::NonExistentQueue + false + end end - - def self.queue_name(queue) - /(?<name>[^\/]+)$/.match(queue)[:name] - end - end end end end