Class: SolidQueue::Configuration

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/solid_queue/configuration.rb

Defined Under Namespace

Classes: Process

Constant Summary collapse

WORKER_DEFAULTS =
{
  queues: "*",
  threads: 3,
  processes: 1,
  polling_interval: 0.1
}
DISPATCHER_DEFAULTS =
{
  batch_size: 500,
  polling_interval: 1,
  concurrency_maintenance: true,
  concurrency_maintenance_interval: 600
}
DEFAULT_CONFIG_FILE_PATH =
"config/queue.yml"
DEFAULT_RECURRING_SCHEDULE_FILE_PATH =
"config/recurring.yml"

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Configuration

Returns a new instance of Configuration.



34
35
36
# File 'lib/solid_queue/configuration.rb', line 34

def initialize(**options)
  @options = options.with_defaults(default_options)
end

Instance Method Details

#configured_processesObject



38
39
40
41
42
43
# File 'lib/solid_queue/configuration.rb', line 38

def configured_processes
  if only_work? then workers
  else
    dispatchers + workers + schedulers
  end
end

#error_messagesObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/solid_queue/configuration.rb', line 45

def error_messages
  if configured_processes.none?
    "No workers or processed configured. Exiting..."
  else
    error_messages = invalid_tasks.map do |task|
        all_messages = task.errors.full_messages.map { |msg| "\t#{msg}" }.join("\n")
        "#{task.key}:\n#{all_messages}"
      end
      .join("\n")

    "Invalid processes configured:\n#{error_messages}"
  end
end