Class: Superbolt::Runner::Pop

Inherits:
Base
  • Object
show all
Defined in:
lib/superbolt/runner/pop.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#block, #error_queue, #logger, #queue

Instance Method Summary collapse

Methods inherited from Base

#channel, #initialize, #on_error

Constructor Details

This class inherits a constructor from Superbolt::Runner::Base

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/superbolt/runner/pop.rb', line 4

def message
  @message
end

Instance Method Details

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/superbolt/runner/pop.rb', line 6

def run
  EventMachine.add_periodic_timer(0.01) do
    next unless queue.message_count > 0


    queue.pop do |delivery_info, , payload|
      @message = IncomingMessage.new(delivery_info, payload, channel)
      processor = Processor.new(message, logger, &block)
      unless processor.perform
        on_error(message.parse, processor.exception) if message.parse
      end
      @message = nil
    end
  end
end