Class: Resque::Plugins::Director::Scaler
- Inherits:
-
Object
- Object
- Resque::Plugins::Director::Scaler
- Defined in:
- lib/resque/plugins/director/scaler.rb
Class Method Summary collapse
- .scale_down(number_of_workers = 1) ⇒ Object
- .scale_down_to_minimum ⇒ Object
- .scale_up(number_of_workers = 1) ⇒ Object
- .scale_within_requirements ⇒ Object
- .scaling(number_of_workers = 1) ⇒ Object
Class Method Details
.scale_down(number_of_workers = 1) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/resque/plugins/director/scaler.rb', line 14 def scale_down(number_of_workers=1) number_of_workers = WorkerTracker.total_to_remove(number_of_workers) scaling(number_of_workers) do stop(number_of_workers) end end |
.scale_down_to_minimum ⇒ Object
21 22 23 24 |
# File 'lib/resque/plugins/director/scaler.rb', line 21 def scale_down_to_minimum number_of_workers = WorkerTracker.total_to_go_to_minimum stop(number_of_workers) end |
.scale_up(number_of_workers = 1) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/resque/plugins/director/scaler.rb', line 7 def scale_up(number_of_workers=1) number_of_workers = WorkerTracker.total_to_add(number_of_workers) scaling(number_of_workers) do start(number_of_workers) end end |
.scale_within_requirements ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/resque/plugins/director/scaler.rb', line 26 def scale_within_requirements number_of_workers = WorkerTracker.total_for_requirements if number_of_workers > 0 set_last_scaled unless start(number_of_workers) == false elsif number_of_workers < 0 set_last_scaled unless stop(number_of_workers * -1) == false end end |
.scaling(number_of_workers = 1) ⇒ Object
35 36 37 38 |
# File 'lib/resque/plugins/director/scaler.rb', line 35 def scaling(number_of_workers=1) return unless time_to_scale? && number_of_workers > 0 set_last_scaled unless yield == false end |