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.
9 10 11 12 13 14 15 16 17 |
# File 'lib/upperkut/manager.rb', line 9 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.
7 8 9 |
# File 'lib/upperkut/manager.rb', line 7 def logger @logger end |
#redis ⇒ Object
Returns the value of attribute redis.
6 7 8 |
# File 'lib/upperkut/manager.rb', line 6 def redis @redis end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
7 8 9 |
# File 'lib/upperkut/manager.rb', line 7 def stopped @stopped end |
#worker ⇒ Object
Returns the value of attribute worker.
6 7 8 |
# File 'lib/upperkut/manager.rb', line 6 def worker @worker end |
Instance Method Details
#kill ⇒ Object
31 32 33 |
# File 'lib/upperkut/manager.rb', line 31 def kill @processors.each(&:kill) end |
#notify_killed_processor(processor) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/upperkut/manager.rb', line 35 def notify_killed_processor(processor) @processors.delete(processor) return if @stopped processor = Processor.new(self) @processors << processor processor.run end |
#run ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/upperkut/manager.rb', line 19 def run @concurrency.times do processor = Processor.new(self) @processors << processor processor.run end end |
#stop ⇒ Object
27 28 29 |
# File 'lib/upperkut/manager.rb', line 27 def stop @stopped = true end |