Sha256: 6ef99a9f52ae0a3bffae7ae689900297066a98231b4fda38bd9934f0306e7af1

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

module NimbleNodes
      
  class Report
    def initialize(env)
      @dynos_in_use = env['HTTP_X_HEROKU_DYNOS_IN_USE']
      @request_queue_depth = env['HTTP_X_HEROKU_QUEUE_DEPTH']
    end
    
    def post
      params = {
        :dynos_in_use => @dynos_in_use,
        :request_queue_size => @request_queue_depth }
      NimbleNodes::Server.post('/dynos/reports.json', params)
    end
    
    def post?
      return true
      dynos_maxed_out? or queue_depth_too_long?
    end
    
    def dynos_maxed_out?
      return false if @dynos_in_use.nil?
      @dynos_in_use >= Dynos.max
    end
  
    def queue_depth_too_long?
      return false if @request_queue_depth.nil?
      @request_queue_depth > Dynos.max_request_queue
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nimble_nodes-0.1.3 lib/nimble_nodes/report.rb