Class: Upperkut::Manager
- Inherits:
-
Object
- Object
- Upperkut::Manager
- Defined in:
- lib/upperkut/manager.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
-
#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 |
# File 'lib/upperkut/manager.rb', line 10 def initialize(opts = {}) self.worker = opts.fetch(:worker).constantize @concurrency = opts.fetch(:concurrency, 1) @logger = opts.fetch(:logger, Upperkut::Logging.logger) @stopped = false @processors = [] end |
Instance Attribute Details
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
8 9 10 |
# File 'lib/upperkut/manager.rb', line 8 def concurrency @concurrency end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/upperkut/manager.rb', line 8 def logger @logger end |
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
8 9 10 |
# File 'lib/upperkut/manager.rb', line 8 def processors @processors 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
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 |