Sha256: 31e93057825530a8bc3fd0581f4a64e2d123b96547c1578f1bc98c901ff17ed4

Contents?: true

Size: 984 Bytes

Versions: 4

Compression:

Stored size: 984 Bytes

Contents

module HerokuResqueAutoScale
  module Config
    extend self
    
    CONFIG_FILE_NAME = 'scaler_config.yml'
    
    def thresholds
      @thresholds ||= begin
        if config_file?
          config['thresholds']
        else
          [{workers:1,job_count:1},{workers:2,job_count:15},{workers:3,job_count:25},{workers:4,job_count:40},{workers:5,job_count:60}]
        end
      end
    end
    
    def environments
      @environments ||= begin
        if config_file?
          config['environments']
        else
          [ 'production' ]
        end
      end
    end
    
    private 
    
    def config_file?
      @config_file ||= override? || File.exists?(CONFIG_FILE_NAME)
    end
    
    def config
      @config ||= override? ? YAML.load_file(Rails.root.join("config/#{CONFIG_FILE_NAME}").to_s) : YAML.load_file(CONFIG_FILE_NAME)
    end
    
    def override?
      File.exists?(Rails.root.join("config/#{CONFIG_FILE_NAME}").to_s) rescue false
    end
  end
end
  

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
heroku-resque-workers-scaler-0.1.9 lib/heroku-resque-workers-scaler/config.rb
heroku-resque-workers-scaler-0.1.8 lib/heroku-resque-workers-scaler/config.rb
heroku-resque-workers-scaler-0.1.7 lib/heroku-resque-workers-scaler/config.rb
heroku-resque-workers-scaler-0.1.6 lib/heroku-resque-workers-scaler/config.rb