Class: Liebre::Runner::Consumers
- Inherits:
-
Object
- Object
- Liebre::Runner::Consumers
- Defined in:
- lib/liebre/runner/consumers.rb
Instance Method Summary collapse
- #consumer_names ⇒ Object
-
#initialize(connection_manager) ⇒ Consumers
constructor
A new instance of Consumers.
- #start(name) ⇒ Object
- #start_all ⇒ Object
Constructor Details
#initialize(connection_manager) ⇒ Consumers
Returns a new instance of Consumers.
5 6 7 |
# File 'lib/liebre/runner/consumers.rb', line 5 def initialize connection_manager @connection_manager = connection_manager end |
Instance Method Details
#consumer_names ⇒ Object
9 10 11 |
# File 'lib/liebre/runner/consumers.rb', line 9 def consumer_names consumers.keys end |
#start(name) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/liebre/runner/consumers.rb', line 17 def start name params = consumers.fetch(name) num_threads = params.fetch("num_threads", 1) num_threads.times do starter = Starter.new(connection_manager, params) starter.call end end |
#start_all ⇒ Object
13 14 15 |
# File 'lib/liebre/runner/consumers.rb', line 13 def start_all consumer_names.each { |name| start(name) } end |