Class: Alephant::Queue
- Inherits:
-
Object
- Object
- Alephant::Queue
- Defined in:
- lib/alephant/models/queue.rb
Instance Attribute Summary collapse
-
#q ⇒ Object
Returns the value of attribute q.
Instance Method Summary collapse
-
#initialize(id) ⇒ Queue
constructor
A new instance of Queue.
- #poll(*args, &block) ⇒ Object
- #sleep_until_queue_exists ⇒ Object
Constructor Details
#initialize(id) ⇒ Queue
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/alephant/models/queue.rb', line 7 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 |
Instance Attribute Details
#q ⇒ Object
Returns the value of attribute q.
5 6 7 |
# File 'lib/alephant/models/queue.rb', line 5 def q @q end |
Instance Method Details
#poll(*args, &block) ⇒ Object
26 27 28 29 |
# File 'lib/alephant/models/queue.rb', line 26 def poll(*args, &block) @logger.info("Queue.poll: polling with arguments #{args}") @q.poll(*args, &block) end |
#sleep_until_queue_exists ⇒ Object
22 23 24 |
# File 'lib/alephant/models/queue.rb', line 22 def sleep_until_queue_exists sleep 1 until @q.exists? end |