class OurEelHacks::Middleware
Public Class Methods
new(flavor)
click to toggle source
# File lib/our-eel-hacks/middleware.rb, line 5 def initialize(flavor) @flavor = flavor @canary_string = "Canary: #{Time.now.to_s}" end
Protected Instance Methods
autoscale(metric)
click to toggle source
# File lib/our-eel-hacks/middleware.rb, line 12 def autoscale(metric) now = Time.now canary = @canary_string.dup if @scaling_at.nil? or (now - @scaling_at) > 60 @scaling_at = now trigger_scaling(metric, canary) end end
trigger_scaling(metric, canary)
click to toggle source
# File lib/our-eel-hacks/middleware.rb, line 21 def trigger_scaling(metric, canary) unless @canary_string == canary raise "Canary died: #{@canary_string} != #{canary}" end Autoscaler.instance_for(@flavor).scale(metric) @scaling_at = nil end