Sha256: 08dfed05ec6e25e7ec13d55662ca1bc132357015c99e2b97e33346c836dde987

Contents?: true

Size: 537 Bytes

Versions: 2

Compression:

Stored size: 537 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
          client.set_workers(ENV['APP_NAME'], 0) 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

2 entries across 2 versions & 1 rubygems

Version Path
rcarvalho-workless-1.0.2.2 lib/workless/scalers/heroku.rb
rcarvalho-workless-1.0.2.1 lib/workless/scalers/heroku.rb