Class: Upperkut::Manager
- Inherits:
-
Object
- Object
- Upperkut::Manager
- Defined in:
- lib/upperkut/manager.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#redis ⇒ Object
Returns the value of attribute redis.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Manager
constructor
A new instance of Manager.
- #kill ⇒ Object
- #notify_killed_processor(processor) ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Manager
Returns a new instance of Manager.
10 11 12 13 14 15 16 17 18 |
# File 'lib/upperkut/manager.rb', line 10 def initialize(opts = {}) self.worker = opts.fetch(:worker).constantize self.redis = worker.setup.redis @concurrency = opts.fetch(:concurrency, 25) @logger = opts.fetch(:logger, Upperkut::Logging.logger) @stopped = false @processors = [] end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/upperkut/manager.rb', line 8 def logger @logger end |
#redis ⇒ Object
Returns the value of attribute redis.
7 8 9 |
# File 'lib/upperkut/manager.rb', line 7 def redis @redis end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
8 9 10 |
# File 'lib/upperkut/manager.rb', line 8 def stopped @stopped end |
#worker ⇒ Object
Returns the value of attribute worker.
7 8 9 |
# File 'lib/upperkut/manager.rb', line 7 def worker @worker end |
Instance Method Details
#kill ⇒ Object
32 33 34 |
# File 'lib/upperkut/manager.rb', line 32 def kill @processors.each(&:kill) end |
#notify_killed_processor(processor) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/upperkut/manager.rb', line 36 def notify_killed_processor(processor) @processors.delete(processor) return if @stopped processor = Processor.new(self) @processors << processor processor.run end |
#run ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/upperkut/manager.rb', line 20 def run @concurrency.times do processor = Processor.new(self) @processors << processor processor.run end end |
#stop ⇒ Object
28 29 30 |
# File 'lib/upperkut/manager.rb', line 28 def stop @stopped = true end |