Sha256: 4ee99b78a355ea153297b3868780ea17aedb5bcf4622def5bcff90dcb729baae

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

require 'heroku'

module Delayed
  module Workless
    module Scaler

      class HerokuCedar < Base

        extend Delayed::Workless::Scaler::HerokuClient

        def self.up
          nw = self.calculate_num_workers
          if nw
            if self.num_workers_cache != nw
              self.num_workers_cache = nw
              client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => 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.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => nw)
            end
          end          
        rescue
        end

        def self.workers
          self.num_workers_cache
        end

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rcarvalho-workless-1.0.2.13 lib/workless/scalers/heroku_cedar.rb
rcarvalho-workless-1.0.2.12 lib/workless/scalers/heroku_cedar.rb
rcarvalho-workless-1.0.2.11 lib/workless/scalers/heroku_cedar.rb