Sha256: 4ad2b4f6e49ef483cc51d182111a7067b08338b03b29f14b878db9e96f7f8bef

Contents?: true

Size: 725 Bytes

Versions: 6

Compression:

Stored size: 725 Bytes

Contents

require 'aws-sdk'
require 'alephant/logger'

module Alephant
  module Publisher
    class Queue
      include ::Alephant::Logger

      attr_accessor :q

      def initialize(id)
        @sqs = AWS::SQS.new
        @q = @sqs.queues[id]

        unless @q.exists?
          @q = @sqs.queues.create(id)
          sleep_until_queue_exists
          logger.info("Queue.initialize: created queue with id #{id}")
        end

        logger.info("Queue.initialize: ended with id #{id}")
      end

      def sleep_until_queue_exists
        sleep 1 until @q.exists?
      end

      def poll(*args, &block)
        logger.info("Queue.poll: polling with arguments #{args}")
        @q.poll(*args, &block)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alephant-publisher-0.1.3 lib/alephant/publisher/models/queue.rb
alephant-publisher-0.1.0 lib/alephant/publisher/models/queue.rb
alephant-publisher-0.0.4 lib/alephant/publisher/models/queue.rb
alephant-publisher-0.0.3 lib/alephant/publisher/models/queue.rb
alephant-publisher-0.0.2 lib/alephant/publisher/models/queue.rb
alephant-publisher-0.0.1 lib/alephant/publisher/models/queue.rb