Permalink
Browse files

changed up methods to ensure missing keys don't raise errors

  • Loading branch information...
1 parent 70b0cbc commit 803ff74a8ce6b4d5350c812428bee6e0c94bcd24 Jordan Glasner committed Apr 4, 2010
Showing with 52 additions and 3 deletions.
  1. +52 −3 lib/nimble_nodes/dynos.rb
View
@@ -2,16 +2,65 @@ module NimbleNodes
module Dynos
+ #= Settings
+
+ # shortcut for accessing NimbleNodes.settings[:dynos_pool][key]
+ def self.[](key)
+ NimbleNodes::Dynos.settings[key]
+ end
+
+ def self.settings
+ hash = NimbleNodes::Settings['dynos_pool']
+ hash.nil? ? {} : hash
+ end
+
def self.size
- ENV['NN_DYNOS_POOL_SIZE']
+ NimbleNodes::Dynos['size']
+ end
+
+ def self.min
+ NimbleNodes::Dynos['min']
end
def self.max
- ENV['NN_DYNOS_POOL_MAX']
+ NimbleNodes::Dynos['max']
+ end
+
+ def self.request_queue
+ hash = NimbleNodes::Dynos.settings['request_queue']
+ hash.nil? ? {} : hash
+ end
+
+ def self.min_request_queue
+ NimbleNodes::Dynos.request_queue['min']
end
def self.max_request_queue
- ENV['NN_DYNOS_REQUEST_QUEUE_MAX']
+ NimbleNodes::Dynos.request_queue['max']
+ end
+
+ #= Status Inspector
+
+ def self.paused?
+ not NimbleNodes::Dynos['paused_at'].nil?
+ end
+
+ #= Monitoring
+
+ def self.monitor?
+ NimbleNodes.active? and !NimbleNodes::Dynos.paused?
+ end
+
+
+ # pass over the hash containing Rack env variables
+ # a Report will be created and posted if neccessary
+ def self.monitor(env)
+ begin
+ report = NimbleNodes::Report.new(env)
+ report.post if report.post?
+ rescue
+ # rescues any possible errors to ensure app performace isn't affected
+ end
end
end

0 comments on commit 803ff74

Please sign in to comment.