Sha256: 059cdc910813eafbd6321e4e335ad8f7007d7f9e3f14b9b7da8dd850589e94cf

Contents?: true

Size: 854 Bytes

Versions: 5

Compression:

Stored size: 854 Bytes

Contents

require 'heroku'

module Delayed
  module Workless
    module Scaler

      class Heroku < Base

        extend Delayed::Workless::Scaler::HerokuClient

        def self.up
          nw = self.calculate_num_workers(true)
          if nw
            if self.num_workers_cache != nw
              self.num_workers_cache = nw
              client.set_workers(ENV['APP_NAME'], nw)
            end
          end
        rescue          
        end

        def self.down
          nw = self.calculate_num_workers
          if nw
            if self.num_workers_cache != nw
              self.num_workers_cache = nw
              client.set_workers(ENV['APP_NAME'], nw)
            end
          end          
        rescue
        end

        def self.workers
          client.info(ENV['APP_NAME'])[:workers].to_i
        end

      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rcarvalho-workless-1.0.2.21 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.20 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.19 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.18 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.17 lib/workless/scalers/heroku.rb