Module: HireFire

Defined in:
lib/hirefire.rb,
lib/hirefire/logger.rb,
lib/hirefire/backend.rb,
lib/hirefire/railtie.rb,
lib/hirefire/version.rb,
lib/hirefire/environment.rb,
lib/hirefire/initializer.rb,
lib/hirefire/configuration.rb,
lib/hirefire/environment/base.rb,
lib/hirefire/environment/noop.rb,
lib/hirefire/environment/local.rb,
lib/hirefire/environment/heroku.rb,
lib/hirefire/backend/resque/redis.rb,
lib/hirefire/backend/delayed_job/mongoid.rb,
lib/hirefire/backend/delayed_job/active_record.rb

Defined Under Namespace

Modules: Backend, Environment, Version, Workers Classes: Configuration, Initializer, Logger, Railtie

Constant Summary collapse

LIB_PATH =

HireFire constants

File.dirname(__FILE__)
HIREFIRE_PATH =
File.join(LIB_PATH,      'hirefire')
ENVIRONMENT_PATH =
File.join(HIREFIRE_PATH, 'environment')
BACKEND_PATH =
File.join(HIREFIRE_PATH, 'backend')
WORKERS_PATH =
File.join(HIREFIRE_PATH, 'workers')

Class Method Summary collapse

Class Method Details

.configurationObject

Instantiates a new HireFire::Configuration instance and instance variable caches it



92
93
94
# File 'lib/hirefire.rb', line 92

def self.configuration
  @configuration ||= HireFire::Configuration.new
end

.configure {|config| ... } ⇒ nil

Note:

Every param has it’s own defaults. It’s best to leave the environment param at “nil”. When environment is set to “nil”, it’ll default to the :noop environment. This basically means that you have to run “rake jobs:work” yourself from the console to get the jobs running in development mode. In production, it’ll automatically use :heroku if deployed to the Heroku platform.

This method is used to configure HireFire

Examples:

HireFire.configure do |config|
  config.environment      = nil
  config.max_workers      = 5
  config.job_worker_ratio = [
    { :jobs => 1,   :workers => 1 },
    { :jobs => 15,  :workers => 2 },
    { :jobs => 35,  :workers => 3 },
    { :jobs => 60,  :workers => 4 },
    { :jobs => 80,  :workers => 5 }
  ]
end

Yields:

  • (config)

    the instance of HireFire::Configuration class

Yield Parameters:

  • max_workers (Fixnum)

    default: 1 (set at least 1)

  • job_worker_ratio (Array)

    default: see example

  • environment (Symbol, nil)

    (:heroku, :local, :noop or nil) - default: nil

Returns:

  • (nil)


85
86
87
# File 'lib/hirefire.rb', line 85

def self.configure
  yield(configuration); nil
end