Class: Alephant::Publisher::SQSHelper::Queue

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/alephant/publisher/sqs_helper/queue.rb

Constant Summary collapse

WAIT_TIME =
5
VISABILITY_TIMEOUT =
300

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, archiver = nil, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME) ⇒ Queue

Returns a new instance of Queue.



15
16
17
18
19
20
21
22
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 15

def initialize(queue, archiver = nil, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME)
  @queue     = queue
  @archiver  = archiver
  @timeout   = timeout
  @wait_time = wait_time

  logger.debug("Queue#initialize: reading from #{queue.url}")
end

Instance Attribute Details

#archiverObject (readonly)

Returns the value of attribute archiver.



13
14
15
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 13

def archiver
  @archiver
end

#queueObject (readonly)

Returns the value of attribute queue.



13
14
15
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 13

def queue
  @queue
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



13
14
15
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 13

def timeout
  @timeout
end

#wait_timeObject (readonly)

Returns the value of attribute wait_time.



13
14
15
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 13

def wait_time
  @wait_time
end

Instance Method Details

#messageObject



24
25
26
# File 'lib/alephant/publisher/sqs_helper/queue.rb', line 24

def message
  receive.tap { |m| process(m) unless m.nil? }
end