class OurEelHacks::Rack
Public Class Methods
new(app, env_fields, flavor = :web)
click to toggle source
Calls superclass method
OurEelHacks::Middleware::new
# File lib/our-eel-hacks/rack.rb, line 7 def initialize(app, env_fields, flavor = :web) super(flavor) @env_fields = [*env_fields].map(&:to_s) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/our-eel-hacks/rack.rb, line 13 def call(env) begin autoscale(metrics_from(env)) rescue => ex puts "Problem in autoscaling: #{ex.inspect}" end @app.call(env) end
metrics_from(env)
click to toggle source
# File lib/our-eel-hacks/rack.rb, line 23 def metrics_from(env) Hash[ @env_fields.map do |field| [field, (Integer(env[field]) rescue 0)] end ] end