Class: Alephant::Publisher::Queue
- Inherits:
-
Object
- Object
- Alephant::Publisher::Queue
- Includes:
- Logger
- Defined in:
- lib/alephant/publisher/queue.rb
Constant Summary collapse
- WAIT_TIME =
5- VISABILITY_TIMEOUT =
300
Instance Attribute Summary collapse
-
#q ⇒ Object
Returns the value of attribute q.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#wait_time ⇒ Object
readonly
Returns the value of attribute wait_time.
Instance Method Summary collapse
-
#initialize(id, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME) ⇒ Queue
constructor
A new instance of Queue.
- #message ⇒ Object
- #sleep_until_queue_exists ⇒ Object
Constructor Details
#initialize(id, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME) ⇒ Queue
Returns a new instance of Queue.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/alephant/publisher/queue.rb', line 15 def initialize(id, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME) @timeout = timeout @wait_time = wait_time @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.
13 14 15 |
# File 'lib/alephant/publisher/queue.rb', line 13 def q @q end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
12 13 14 |
# File 'lib/alephant/publisher/queue.rb', line 12 def timeout @timeout end |
#wait_time ⇒ Object (readonly)
Returns the value of attribute wait_time.
12 13 14 |
# File 'lib/alephant/publisher/queue.rb', line 12 def wait_time @wait_time end |
Instance Method Details
#message ⇒ Object
34 35 36 37 38 39 |
# File 'lib/alephant/publisher/queue.rb', line 34 def @q.({ :visibility_timeout => @timeout, :wait_time_seconds => @wait_time }) end |
#sleep_until_queue_exists ⇒ Object
30 31 32 |
# File 'lib/alephant/publisher/queue.rb', line 30 def sleep_until_queue_exists sleep 1 until @q.exists? end |