Class: NimbleNodes::Report
- Inherits:
-
Object
- Object
- NimbleNodes::Report
- Defined in:
- lib/nimble_nodes/report.rb
Instance Method Summary collapse
-
#dynos_maxed_out? ⇒ Boolean
returns true if app is using all available dynos.
-
#idle_dynos? ⇒ Boolean
returns true if app isn’t using all of it’s dynos.
-
#initialize(env) ⇒ Report
constructor
A new instance of Report.
- #post ⇒ Object
-
#post? ⇒ Boolean
returns true if report needs to be posted to server.
-
#queue_depth_too_long? ⇒ Boolean
returns true if queue depth is over max.
- #queue_depth_too_short? ⇒ Boolean
Constructor Details
#initialize(env) ⇒ Report
Returns a new instance of Report.
5 6 7 8 |
# File 'lib/nimble_nodes/report.rb', line 5 def initialize(env) @dynos_in_use = env['HTTP_X_HEROKU_DYNOS_IN_USE'].to_i @request_queue_depth = env['HTTP_X_HEROKU_QUEUE_DEPTH'].to_i end |
Instance Method Details
#dynos_maxed_out? ⇒ Boolean
returns true if app is using all available dynos
24 25 26 27 |
# File 'lib/nimble_nodes/report.rb', line 24 def dynos_maxed_out? return false if @dynos_in_use.nil? @dynos_in_use >= NimbleNodes::Dynos.max end |
#idle_dynos? ⇒ Boolean
returns true if app isn’t using all of it’s dynos
41 42 43 44 |
# File 'lib/nimble_nodes/report.rb', line 41 def idle_dynos? return false if @dynos_in_use.nil? @dynos_in_use < NimbleNodes::Dynos.size end |
#post ⇒ Object
10 11 12 13 14 15 |
# File 'lib/nimble_nodes/report.rb', line 10 def post params = { :dynos_in_use => @dynos_in_use, :request_queue_size => @request_queue_depth } NimbleNodes::Server.post('/dynos/reports.json', params) end |
#post? ⇒ Boolean
returns true if report needs to be posted to server
18 19 20 21 |
# File 'lib/nimble_nodes/report.rb', line 18 def post? # return true dynos_maxed_out? or queue_depth_too_long? or queue_depth_too_short? or idle_dynos? end |
#queue_depth_too_long? ⇒ Boolean
returns true if queue depth is over max
30 31 32 33 |
# File 'lib/nimble_nodes/report.rb', line 30 def queue_depth_too_long? return false if @request_queue_depth.nil? @request_queue_depth > NimbleNodes::Dynos.max_request_queue end |
#queue_depth_too_short? ⇒ Boolean
35 36 37 38 |
# File 'lib/nimble_nodes/report.rb', line 35 def queue_depth_too_short? return false if @request_queue_depth.nil? @request_queue_depth < NimbleNodes::Dynos.min_request_queue end |