Sha256: bee01c8e2fbab643471ac55d63b42fdb16c417a5a39edaee1a746b5e38fe5155
Contents?: true
Size: 1.1 KB
Versions: 20
Compression:
Stored size: 1.1 KB
Contents
require 'workless/scalers/heroku' require 'workless/scalers/heroku_cedar' require 'workless/scalers/local' require 'workless/scalers/null' module Delayed module Workless module Scaler def self.included(base) base.send :extend, ClassMethods base.class_eval do after_destroy "self.class.scaler.down" before_create "self.class.scaler.up" after_update "self.class.scaler.down", :unless => Proc.new {|r| r.failed_at.nil? } end end module ClassMethods def scaler @scaler ||= if ENV.include?("HEROKU_USER") client = ::Heroku::Client.new(ENV['HEROKU_USER'], ENV['HEROKU_PASSWORD']) case client.info(ENV["APP_NAME"])[:stack] when "cedar" Scaler::HerokuCedar else Scaler::Heroku end else Scaler::Local end end def scaler=(scaler) @scaler = "Delayed::Workless::Scaler::#{scaler.to_s.camelize}".constantize end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems