Sha256: 87b2d42c1c105bd56cf252bcb80263d429f5a0d34f606db73c29338a899ff4d0

Contents?: true

Size: 659 Bytes

Versions: 5

Compression:

Stored size: 659 Bytes

Contents

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

module Alephant
  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alephant-0.1.4.1-java lib/alephant/models/queue.rb
alephant-0.1.4-java lib/alephant/models/queue.rb
alephant-0.1.3-java lib/alephant/models/queue.rb
alephant-0.1.2-java lib/alephant/models/queue.rb
alephant-0.1.1-java lib/alephant/models/queue.rb