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

Accept except-queues parameter #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions lib/delayed/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def initialize(args) # rubocop:disable MethodLength
opt.on('--queue=queue', 'Specify which queue DJ must look up for jobs') do |queue|
@options[:queues] = queue.split(',')
end
opt.on('--except-queues=queues', 'Specify queues to ignore for this worker or a worker pool') do |queues|
@options[:except_queues] = queues.split(',')
end
opt.on('--pool=queue1[,queue2][:worker_count]', 'Specify queues and number of workers for a worker pool') do |pool|
parse_worker_pool(pool)
end
Expand Down
1 change: 1 addition & 0 deletions lib/delayed/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:min_priority => ENV['MIN_PRIORITY'],
:max_priority => ENV['MAX_PRIORITY'],
:queues => (ENV['QUEUES'] || ENV['QUEUE'] || '').split(','),
:except_queues => (ENV['EXCEPT_QUEUES'] || ENV['EXCEPT_QUEUE'] || '').split(','),
:quiet => ENV['QUIET']
}

Expand Down
8 changes: 5 additions & 3 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ class Worker # rubocop:disable ClassLength
DEFAULT_DEFAULT_PRIORITY = 0
DEFAULT_DELAY_JOBS = true
DEFAULT_QUEUES = [].freeze
DEFAULT_EXCEPT_QUEUES = [].freeze
DEFAULT_QUEUE_ATTRIBUTES = HashWithIndifferentAccess.new.freeze
DEFAULT_READ_AHEAD = 5

cattr_accessor :min_priority, :max_priority, :max_attempts, :max_run_time,
:default_priority, :sleep_delay, :logger, :delay_jobs, :queues,
:read_ahead, :plugins, :destroy_failed_jobs, :exit_on_complete,
:default_log_level
:except_queues, :read_ahead, :plugins, :destroy_failed_jobs,
:exit_on_complete, :default_log_level

# Named queue into which jobs are enqueued by default
cattr_accessor :default_queue_name
Expand All @@ -41,6 +42,7 @@ def self.reset
self.default_priority = DEFAULT_DEFAULT_PRIORITY
self.delay_jobs = DEFAULT_DELAY_JOBS
self.queues = DEFAULT_QUEUES
self.except_queues = DEFAULT_EXCEPT_QUEUES
self.queue_attributes = DEFAULT_QUEUE_ATTRIBUTES
self.read_ahead = DEFAULT_READ_AHEAD
@lifecycle = nil
Expand Down Expand Up @@ -132,7 +134,7 @@ def initialize(options = {})
@quiet = options.key?(:quiet) ? options[:quiet] : true
@failed_reserve_count = 0

[:min_priority, :max_priority, :sleep_delay, :read_ahead, :queues, :exit_on_complete].each do |option|
[:min_priority, :max_priority, :sleep_delay, :read_ahead, :queues, :except_queues, :exit_on_complete].each do |option|
self.class.send("#{option}=", options[option]) if options.key?(option)
end

Expand Down