Class: Heroku::Autoscale

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku/autoscale.rb

Constant Summary collapse

VERSION =
"0.2.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Autoscale

Returns a new instance of Autoscale.



12
13
14
15
16
17
# File 'lib/heroku/autoscale.rb', line 12

def initialize(app, options={})
  @app = app
  @options = default_options.merge(options)
  @last_scaled = Time.now - 60
  check_options!
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'lib/heroku/autoscale.rb', line 10

def app
  @app
end

#last_scaledObject (readonly)

Returns the value of attribute last_scaled.



10
11
12
# File 'lib/heroku/autoscale.rb', line 10

def last_scaled
  @last_scaled
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/heroku/autoscale.rb', line 10

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/heroku/autoscale.rb', line 19

def call(env)
  if env["PATH_INFO"] == "/autoscale/#{options[:autoscale_key]}"
    autoscale env
    [200, {'Content-Type' => 'text/plain'}, ["Current wait time: #{env["HTTP_X_HEROKU_QUEUE_WAIT_TIME"]}"]]
  else
    app.call(env)
  end 
end