Class: Shoryuken::EnvironmentLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/environment_loader.rb

Overview

Loads and configures the Shoryuken environment from configuration files and command line options. Handles Rails integration and queue setup.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ EnvironmentLoader

Initializes a new EnvironmentLoader with the given options

Parameters:

  • options (Hash)

    configuration options

Options Hash (options):

  • :config_file (String)

    path to the configuration file

  • :rails (Boolean)

    whether to initialize Rails

  • :logfile (String)

    path to the log file

  • :verbose (Boolean)

    whether to enable verbose logging

  • :require (String)

    path to require workers from

  • :concurrency (Integer)

    number of concurrent workers



43
44
45
# File 'lib/shoryuken/environment_loader.rb', line 43

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsHash (readonly)

Returns the configuration options.

Returns:

  • (Hash)

    the configuration options



8
9
10
# File 'lib/shoryuken/environment_loader.rb', line 8

def options
  @options
end

Class Method Details

.load_for_rails_consolevoid

This method returns an undefined value.

Loads the environment for Rails console usage



29
30
31
32
# File 'lib/shoryuken/environment_loader.rb', line 29

def self.load_for_rails_console
  instance = setup_options(config_file: (Rails.root + 'config' + 'shoryuken.yml'))
  instance.load
end

.setup_options(options) ⇒ Shoryuken::EnvironmentLoader

Sets up a new EnvironmentLoader with the given options

Parameters:

  • options (Hash)

    configuration options

Options Hash (options):

  • :config_file (String)

    path to the configuration file

  • :rails (Boolean)

    whether to initialize Rails

  • :logfile (String)

    path to the log file

  • :verbose (Boolean)

    whether to enable verbose logging

  • :require (String)

    path to require workers from

  • :concurrency (Integer)

    number of concurrent workers

Returns:



20
21
22
23
24
# File 'lib/shoryuken/environment_loader.rb', line 20

def self.setup_options(options)
  instance = new(options)
  instance.setup_options
  instance
end

Instance Method Details

#loadvoid

This method returns an undefined value.

Loads the environment including queues and workers



59
60
61
62
63
64
65
# File 'lib/shoryuken/environment_loader.rb', line 59

def load
  prefix_active_job_queue_names
  parse_queues
  require_workers
  validate_queues
  validate_workers
end

#setup_optionsvoid

This method returns an undefined value.

Sets up configuration options from file and initializes components



50
51
52
53
54
# File 'lib/shoryuken/environment_loader.rb', line 50

def setup_options
  initialize_rails if load_rails?
  initialize_options
  initialize_logger
end