Sha256: da87b0f7c5e25cdb03507fb97823f03dad3cc2932e2d1aace0184b6da99d6a0f

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module MessageQueue
  class ConsumableRunner
    include Logging

    attr_reader :consumables

    def initialize(consumables)
      @consumables = consumables
    end

    def run(options = {})
      begin
        block = !!options[:block]
        consumables.each_with_index do |consumable, index|
          # Blocks the last consumer
          opts = if index < consumables.size - 1
                   {}
                 else
                   { :block => block }
                 end
          consumable.new.subscribe(opts)
        end
      rescue SignalException => ex
        logger.info "Received Signal #{ex}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_queue-0.1.1 lib/message_queue/consumable_runner.rb
message_queue-0.1.0 lib/message_queue/consumable_runner.rb