Class: Postburner::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/postburner/runner.rb

Overview

Shared runner logic for bin/postburner and rake tasks.

Provides a unified interface for starting Postburner workers from both the command-line executable and Rake tasks. Handles configuration loading, queue filtering, logging, and worker startup.

Examples:

Using from bin/postburner

options = { config: 'config/postburner.yml', env: 'production', worker: 'default' }
runner = Postburner::Runner.new(options)
runner.run

Using from Rake task

options = { worker: ENV['WORKER'], queues: ENV['QUEUES']&.split(',') }
runner = Postburner::Runner.new(options)
runner.run

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Initialize runner with options.

Parameters:

  • options (Hash) (defaults to: {})

    Runner options

Options Hash (options):

  • :config (String)

    Path to YAML configuration file (default: ‘config/postburner.yml’)

  • :env (String)

    Environment name (default: RAILS_ENV or ‘development’)

  • :worker (String, nil)

    Worker name from config (required if multiple workers defined)

  • :queues (Array<String>, nil)

    List of queue names to filter (overrides config)



35
36
37
38
39
40
41
42
# File 'lib/postburner/runner.rb', line 35

def initialize(options = {})
  @options = {
    config: 'config/postburner.yml',
    env: ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development',
    worker: nil,
    queues: nil
  }.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



26
27
28
# File 'lib/postburner/runner.rb', line 26

def options
  @options
end

Instance Method Details

#runvoid

This method returns an undefined value.

Load configuration, filter queues, and start worker.



47
48
49
50
51
52
# File 'lib/postburner/runner.rb', line 47

def run
  config = load_configuration
  filter_queues(config) if options[:queues]
  log_configuration(config)
  start_worker(config)
end