Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EnvironmentLoader#merge_cli_defined_queues #583

Merged
merged 1 commit into from
Nov 2, 2019
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
12 changes: 0 additions & 12 deletions lib/shoryuken/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def initialize(options)
def setup_options
initialize_options
initialize_logger
merge_cli_defined_queues
end

def load
Expand Down Expand Up @@ -76,17 +75,6 @@ def load_rails
end
end

def merge_cli_defined_queues
cli_defined_queues = options[:queues].to_a

cli_defined_queues.each do |cli_defined_queue|
# CLI defined queues override config_file defined queues
Shoryuken.options[:queues].delete_if { |config_file_queue| config_file_queue[0] == cli_defined_queue[0] }

Shoryuken.options[:queues] << cli_defined_queue
end
end

def prefix_active_job_queue_name(queue_name, weight)
queue_name_prefix = ::ActiveJob::Base.queue_name_prefix
queue_name_delimiter = ::ActiveJob::Base.queue_name_delimiter
Expand Down
24 changes: 24 additions & 0 deletions spec/shoryuken/environment_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,28 @@
expect(Shoryuken.groups['group1'][:queues]).to eq(%w[test_group1_queue1 test_group1_queue2])
end
end
describe "#setup_options" do
let (:cli_queues) { { "queue1"=> 10, "queue2" => 20 } }
let (:config_queues) { [["queue1", 8], ["queue2", 4]] }
context "when given queues through config and CLI" do
specify do
allow_any_instance_of(Shoryuken::EnvironmentLoader).to receive(:config_file_options).and_return({ queues: config_queues })
Shoryuken::EnvironmentLoader.setup_options(queues: cli_queues)
expect(Shoryuken.options[:queues]).to eq(cli_queues)
end
end
context "when given queues through config only" do
specify do
allow_any_instance_of(Shoryuken::EnvironmentLoader).to receive(:config_file_options).and_return({ queues: config_queues })
Shoryuken::EnvironmentLoader.setup_options({})
expect(Shoryuken.options[:queues]).to eq(config_queues)
end
end
context "when given queues through CLI only" do
specify do
Shoryuken::EnvironmentLoader.setup_options(queues: cli_queues)
expect(Shoryuken.options[:queues]).to eq(cli_queues)
end
end
end
end