Module: DynoScaler::Workers::Resque::ClassMethods
- Defined in:
- lib/dyno_scaler/workers/resque.rb
Instance Method Summary collapse
- #after_enqueue_scale_up(*args) ⇒ Object
- #after_perform_scale_down(*args) ⇒ Object
- #disable_scaling_down ⇒ Object
- #disable_scaling_up ⇒ Object
- #enable_scaling_down ⇒ Object
- #enable_scaling_up ⇒ Object
Instance Method Details
#after_enqueue_scale_up(*args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dyno_scaler/workers/resque.rb', line 29 def after_enqueue_scale_up(*args) if scale_up_enabled? if DynoScaler.configuration.async? DynoScaler.configuration.async.call(::Resque.info.merge(action: :scale_up)) else dyno_scaler_manager.scale_up(::Resque.info) end end rescue StandardError => e $stderr.puts "Could not scale up workers: #{e}" end |
#after_perform_scale_down(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/dyno_scaler/workers/resque.rb', line 19 def after_perform_scale_down(*args) info = ::Resque.info working = info[:working] > 0 ? info[:working] - 1 : 0 info.merge!(working: working) # we are not working anymore dyno_scaler_manager.scale_down(info) if scale_down_enabled? rescue StandardError => e $stderr.puts "Could not scale down workers: #{e}" end |
#disable_scaling_down ⇒ Object
53 54 55 |
# File 'lib/dyno_scaler/workers/resque.rb', line 53 def disable_scaling_down self.scale_down_enabled = false end |
#disable_scaling_up ⇒ Object
49 50 51 |
# File 'lib/dyno_scaler/workers/resque.rb', line 49 def disable_scaling_up self.scale_up_enabled = false end |
#enable_scaling_down ⇒ Object
45 46 47 |
# File 'lib/dyno_scaler/workers/resque.rb', line 45 def enable_scaling_down self.scale_down_enabled = true end |
#enable_scaling_up ⇒ Object
41 42 43 |
# File 'lib/dyno_scaler/workers/resque.rb', line 41 def enable_scaling_up self.scale_up_enabled = true end |