Sha256: 8c540c73905f7c2868e6758cdd63d8cd755e1f43c7c62d5585fdb186bc5f33da

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 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
          client.set_workers(ENV['APP_NAME'], nw) if nw
        end

        def self.down
          nw = self.calculate_num_workers
          client.set_workers(ENV['APP_NAME'], nw) unless self.workers == 0 or self.jobs.count > 0
        end

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

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rcarvalho-workless-1.0.2.5 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.4 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.3 lib/workless/scalers/heroku.rb