Class: Soda::Manager
- Inherits:
-
Object
- Object
- Soda::Manager
- Defined in:
- lib/soda/manager.rb
Instance Attribute Summary collapse
-
#fetcher ⇒ Object
readonly
Returns the value of attribute fetcher.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
-
#on_died(worker) ⇒ Object
A processor will die on failed job execution.
- #shutdown! ⇒ Object
- #shutdown? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Attribute Details
#fetcher ⇒ Object (readonly)
Returns the value of attribute fetcher.
3 4 5 |
# File 'lib/soda/manager.rb', line 3 def fetcher @fetcher end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
43 44 45 |
# File 'lib/soda/manager.rb', line 43 def mutex @mutex end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
43 44 45 |
# File 'lib/soda/manager.rb', line 43 def workers @workers end |
Instance Method Details
#on_died(worker) ⇒ Object
A processor will die on failed job execution. Replace it with a new one.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/soda/manager.rb', line 29 def on_died(worker) mutex.synchronize do workers.delete(worker) unless shutdown? workers << (processor = Processor.new(self)) processor.start end end end |
#shutdown! ⇒ Object
45 46 47 |
# File 'lib/soda/manager.rb', line 45 def shutdown! @shutdown = true end |
#shutdown? ⇒ Boolean
49 50 51 |
# File 'lib/soda/manager.rb', line 49 def shutdown? @shutdown end |
#start ⇒ Object
17 18 19 |
# File 'lib/soda/manager.rb', line 17 def start workers.each(&:start) end |
#stop ⇒ Object
21 22 23 24 25 26 |
# File 'lib/soda/manager.rb', line 21 def stop shutdown! workers.each(&:stop) workers.each(&:finish) end |