Sha256: 6c8814652d413cd172bddd0213e04a85f40ff6eb02a90b4a5c3c92791216a218

Contents?: true

Size: 509 Bytes

Versions: 3

Compression:

Stored size: 509 Bytes

Contents

require 'heroku'

module Delayed
  module Workless
    module Scaler

      class Heroku < Base

        extend Delayed::Workless::Scaler::HerokuClient

        def self.up
          client.set_workers(ENV['APP_NAME'], 1) if self.workers == 0
        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

3 entries across 3 versions & 1 rubygems

Version Path
workless-1.0.2 lib/workless/scalers/heroku.rb
workless-1.0.1 lib/workless/scalers/heroku.rb
workless-1.0.0 lib/workless/scalers/heroku.rb