Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed to match Dynos namespace

  • Loading branch information...
commit 08546786a882cac009f9df11e1a3e32e0085e1f9 1 parent c9cccb9
Jordan Glasner authored
Showing with 16 additions and 14 deletions.
  1. +16 −14 lib/nimble_nodes/report.rb
View
30 lib/nimble_nodes/report.rb
@@ -2,11 +2,6 @@ module NimbleNodes
class Report
-
- def self.path
- "/#{ENV['NN_APP_NAME']}/dynos/reports.json"
- end
-
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
@@ -16,29 +11,36 @@ def post
params = {
:dynos_in_use => @dynos_in_use,
:request_queue_size => @request_queue_depth }
- NimbleNodes::Server.post(self.class.path, params)
+ NimbleNodes::Server.post('/dynos/reports.json', params)
end
+ # returns true if report needs to be posted to server
def post?
- return false unless NimbleNodes.installed?
return true
- return false if NimbleNodes.paused?
- dynos_maxed_out? or queue_depth_too_long? or unused_dynos?
+ dynos_maxed_out? or queue_depth_too_long? or queue_depth_too_short? or idle_dynos?
end
+ # returns true if app is using all available dynos
def dynos_maxed_out?
return false if @dynos_in_use.nil?
- @dynos_in_use >= Dynos.max
+ @dynos_in_use >= NimbleNodes::Dynos.max
end
-
+
+ # returns true if queue depth is over max
def queue_depth_too_long?
return false if @request_queue_depth.nil?
- @request_queue_depth > Dynos.max_request_queue
+ @request_queue_depth > NimbleNodes::Dynos.max_request_queue
+ end
+
+ def queue_depth_too_short?
+ return false if @request_queue_depth.nil?
+ @request_queue_depth < NimbleNodes::Dynos.min_request_queue
end
- def unused_dynos?
+ # returns true if app isn't using all of it's dynos
+ def idle_dynos?
return false if @dynos_in_use.nil?
- @dynos_in_use < Dynos.size
+ @dynos_in_use < NimbleNodes::Dynos.size
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.