Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/solid_queue/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def scheduler
end
end

def max_number_of_threads
# At most pool_size thread in each worker + 1 thread for the worker + 1 thread for the heartbeat task
queues.values.map { |queue| queue[:pool_size] }.max + 2
end

private
attr_reader :raw_config, :mode

Expand Down
2 changes: 1 addition & 1 deletion lib/solid_queue/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Engine < ::Rails::Engine

initializer "solid_queue.app_executor", before: :run_prepare_callbacks do |app|
config.solid_queue.app_executor ||= app.executor
config.solid_queue.on_thread_error ||= -> (exception) { Rails.error.report(exception) }
config.solid_queue.on_thread_error ||= -> (exception) { Rails.error.report(exception, handled: false) }

SolidQueue.app_executor = config.solid_queue.app_executor
SolidQueue.on_thread_error = config.solid_queue.on_thread_error
Expand Down
5 changes: 5 additions & 0 deletions test/unit/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal SolidQueue::Configuration::SCHEDULER_DEFAULTS[:polling_interval], configuration.scheduler.polling_interval
assert configuration.workers.detect { |w| w.queue == "background" }.pool_size > 0
end

test "max number of threads" do
configuration = SolidQueue::Configuration.new(mode: :all)
assert 7, configuration.max_number_of_threads
end
end