lib/woodhouse/layout.rb in woodhouse-0.1.2 vs lib/woodhouse/layout.rb in woodhouse-0.1.5
- old
+ new
@@ -147,11 +147,11 @@
# +config+ is used to determine how many threads should be
# assigned to each worker.
def default_configuration!(config, options = {})
options[:threads] ||= config.default_threads
config.registry.each do |name, klass|
- klass.public_instance_methods(false).each do |method|
+ klass.available_jobs.each do |method|
add_worker Woodhouse::Layout::Worker.new(name, method, options)
end
end
end
@@ -186,20 +186,20 @@
# done via an AMQP headers exchange (TODO: need to have a central document
# to reference on how Woodhouse uses AMQP and jobs are dispatched)
#
class Worker
attr_reader :worker_class_name, :job_method, :threads, :criteria
+ attr_accessor :flags
def initialize(worker_class_name, job_method, opts = {})
opts = opts.clone
self.worker_class_name = worker_class_name
self.job_method = job_method
- self.threads = opts.delete(:threads) || 1
- self.criteria = opts.delete(:only)
- unless opts.keys.empty?
- raise ArgumentError, "unknown option keys: #{opts.keys.inspect}"
- end
+ self.threads = opts.delete(:threads) || 1
+ criteria = opts.delete(:only)
+ self.flags = opts
+ self.criteria = criteria
end
def exchange_name
"#{worker_class_name}_#{job_method}".downcase
end
@@ -219,10 +219,10 @@
def threads=(value)
@threads = value.to_i
end
def criteria=(value)
- @criteria = Woodhouse::QueueCriteria.new(value).freeze
+ @criteria = Woodhouse::QueueCriteria.new(value, flags).freeze
end
def frozen_clone
clone.freeze
end