Module: Resque::Plugins::HerokuScaler::Config
Instance Attribute Summary collapse
- #poll_interval ⇒ Object
- #scale_interval ⇒ Object
- #scale_manager ⇒ Object
- #scale_timeout ⇒ Object
-
#scale_with ⇒ Object
Returns the value of attribute scale_with.
Instance Method Summary collapse
Instance Attribute Details
#poll_interval ⇒ Object
21 22 23 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 21 def poll_interval @poll_interval || 1 end |
#scale_interval ⇒ Object
17 18 19 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 17 def scale_interval @scale_interval || 5 end |
#scale_manager ⇒ Object
13 14 15 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 13 def scale_manager @scale_manager || :heroku end |
#scale_timeout ⇒ Object
25 26 27 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 25 def scale_timeout @scale_timeout || 90 end |
#scale_with ⇒ Object
Returns the value of attribute scale_with.
11 12 13 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 11 def scale_with @scale_with end |
Instance Method Details
#default_scale_with(pending) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 38 def default_scale_with(pending) return 0 if pending <= 0 [{ :workers => 1, :jobs => 1 }, { :workers => 2, :jobs => 15 }, { :workers => 3, :jobs => 25 }, { :workers => 4, :jobs => 40 }, { :workers => 5, :jobs => 60 } ].reverse_each do |required_scale| if pending >= required_scale[:jobs] return required_scale[:workers] end end return 0 end |
#scale_for(pending) ⇒ Object
29 30 31 32 |
# File 'lib/resque/plugins/heroku_scaler/config.rb', line 29 def scale_for(pending) return @scale_with.call(pending) if @scale_with default_scale_with(pending) end |