Sha256: 8dadd708b6e5bf6e2fdc7ae724097f1a6ea3061de31f58015633a57fe337e953

Contents?: true

Size: 639 Bytes

Versions: 15

Compression:

Stored size: 639 Bytes

Contents

require 'aws-sdk'

module Alephant
  class Queue
    attr_accessor :q

    def initialize(id)
      @logger = ::Alephant.logger

      @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

15 entries across 15 versions & 1 rubygems

Version Path
alephant-0.0.9.9.1-java lib/alephant/models/queue.rb
alephant-0.0.9.9-java lib/alephant/models/queue.rb
alephant-0.0.9.8-java lib/alephant/models/queue.rb
alephant-0.0.9.7-java lib/alephant/models/queue.rb
alephant-0.0.9.6-java lib/alephant/models/queue.rb
alephant-0.0.9.5-java lib/alephant/models/queue.rb
alephant-0.0.9.4-java lib/alephant/models/queue.rb
alephant-0.0.9.3-java lib/alephant/models/queue.rb
alephant-0.0.9.2-java lib/alephant/models/queue.rb
alephant-0.0.9.1-java lib/alephant/models/queue.rb
alephant-0.0.9-java lib/alephant/models/queue.rb
alephant-0.0.8.2-java lib/alephant/models/queue.rb
alephant-0.0.8.1-java lib/alephant/models/queue.rb
alephant-0.0.8-java lib/alephant/models/queue.rb
alephant-0.0.7-java lib/alephant/models/queue.rb