class Qs::Daemon::Config
Constants
- DEFAULT_NUM_WORKERS
Attributes
error_procs[RW]
init_procs[RW]
logger[RW]
name[RW]
num_workers[RW]
pid_file[RW]
queues[RW]
shutdown_timeout[RW]
verbose_logging[RW]
worker_class[RW]
worker_params[RW]
Public Class Methods
new()
click to toggle source
# File lib/qs/daemon.rb, line 284 def initialize @name = nil @pid_file = nil @shutdown_timeout = nil @worker_class = DefaultWorker @worker_params = nil @num_workers = DEFAULT_NUM_WORKERS @init_procs = [] @error_procs = [] @logger = Qs::NullLogger.new @queues = [] @verbose_logging = true @valid = nil end
Public Instance Methods
routes()
click to toggle source
# File lib/qs/daemon.rb, line 301 def routes @queues.map(&:routes).flatten end
valid?()
click to toggle source
# File lib/qs/daemon.rb, line 305 def valid? !!@valid end
validate!()
click to toggle source
for the config to be considered “valid”, a few things need to happen. The key here is that this only needs to be done once for each config.
# File lib/qs/daemon.rb, line 312 def validate! return @valid if !@valid.nil? # only need to run this once per config # ensure all user and plugin configs/settings are applied self.init_procs.each(&:call) if self.queues.empty? || self.name.nil? raise InvalidError, "a name and at least 1 queue must be configured" end # validate the worker class if !self.worker_class.kind_of?(Class) || !self.worker_class.include?(Qs::Worker) raise InvalidError, "worker class must include `#{Qs::Worker}`" end # validate the routes self.routes.each(&:validate!) @valid = true # if it made it this far, it's valid! end