Class: Proletariat::Runner
- Inherits:
-
Object
- Object
- Proletariat::Runner
- Extended by:
- Forwardable
- Defined in:
- lib/proletariat/runner.rb
Overview
Public: Sets up a supervisor which maintains a single Publisher and a per-worker Manager instance.
Instance Method Summary collapse
-
#run ⇒ Object
Public: Start the workers.
-
#running? ⇒ Boolean
Public: Check whether the workers are currently running.
-
#stop ⇒ Object
Public: Stop the workers.
Instance Method Details
#run ⇒ Object
Public: Start the workers.
Returns nil.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/proletariat/runner.rb', line 10 def run @managers = Proletariat.worker_classes.map do |worker_class| Manager.spawn!(name: "manager_#{worker_class.to_s}_#{object_id}", supervise: true, args: [worker_class]) end managers.each { |manager| manager << :run } nil end |
#running? ⇒ Boolean
Public: Check whether the workers are currently running.
23 24 25 |
# File 'lib/proletariat/runner.rb', line 23 def running? !!managers end |
#stop ⇒ Object
Public: Stop the workers.
Returns nil.
30 31 32 33 34 35 |
# File 'lib/proletariat/runner.rb', line 30 def stop managers.each { |manager| manager << :terminate! } if managers @managers = nil nil end |