Class: MessageQueue::ConsumableRunner
- Inherits:
-
Object
- Object
- MessageQueue::ConsumableRunner
- Includes:
- Logging
- Defined in:
- lib/message_queue/consumable_runner.rb
Instance Attribute Summary collapse
-
#consumables ⇒ Object
readonly
Returns the value of attribute consumables.
Instance Method Summary collapse
-
#initialize(consumables) ⇒ ConsumableRunner
constructor
A new instance of ConsumableRunner.
- #run(options = {}) ⇒ Object
Methods included from Logging
#logger, logger, logger=, setup_logger
Constructor Details
#initialize(consumables) ⇒ ConsumableRunner
7 8 9 |
# File 'lib/message_queue/consumable_runner.rb', line 7 def initialize(consumables) @consumables = consumables end |
Instance Attribute Details
#consumables ⇒ Object (readonly)
Returns the value of attribute consumables.
5 6 7 |
# File 'lib/message_queue/consumable_runner.rb', line 5 def consumables @consumables end |
Instance Method Details
#run(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/message_queue/consumable_runner.rb', line 11 def run( = {}) begin block = !![: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 |