Skip to content

Commit

Permalink
Merge pull request #583 from Drew-Goddyn/remove-merge-cli-queues
Browse files Browse the repository at this point in the history
Remove EnvironmentLoader#merge_cli_defined_queues
  • Loading branch information
phstc committed Nov 2, 2019
2 parents 6215a63 + d11926c commit 8cb18f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
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

0 comments on commit 8cb18f6

Please sign in to comment.