Class: Qs::Daemon::Configuration
- Inherits:
-
Object
- Object
- Qs::Daemon::Configuration
- Includes:
- NsOptions::Proxy
- Defined in:
- lib/qs/daemon.rb
Instance Attribute Summary collapse
-
#error_procs ⇒ Object
Returns the value of attribute error_procs.
-
#init_procs ⇒ Object
Returns the value of attribute init_procs.
-
#process_label ⇒ Object
Returns the value of attribute process_label.
-
#queues ⇒ Object
Returns the value of attribute queues.
-
#worker_shutdown_procs ⇒ Object
readonly
Returns the value of attribute worker_shutdown_procs.
-
#worker_sleep_procs ⇒ Object
readonly
Returns the value of attribute worker_sleep_procs.
-
#worker_start_procs ⇒ Object
readonly
Returns the value of attribute worker_start_procs.
-
#worker_wakeup_procs ⇒ Object
readonly
Returns the value of attribute worker_wakeup_procs.
Instance Method Summary collapse
-
#initialize(values = nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #routes ⇒ Object
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(values = nil) ⇒ Configuration
Returns a new instance of Configuration.
324 325 326 327 328 329 330 331 332 |
# File 'lib/qs/daemon.rb', line 324 def initialize(values = nil) super(values) @process_label = !(v = ENV['QS_PROCESS_LABEL'].to_s).empty? ? v : self.name @init_procs, @error_procs = [], [] @worker_start_procs, @worker_shutdown_procs = [], [] @worker_sleep_procs, @worker_wakeup_procs = [], [] @queues = [] @valid = nil end |
Instance Attribute Details
#error_procs ⇒ Object
Returns the value of attribute error_procs.
319 320 321 |
# File 'lib/qs/daemon.rb', line 319 def error_procs @error_procs end |
#init_procs ⇒ Object
Returns the value of attribute init_procs.
319 320 321 |
# File 'lib/qs/daemon.rb', line 319 def init_procs @init_procs end |
#process_label ⇒ Object
Returns the value of attribute process_label.
318 319 320 |
# File 'lib/qs/daemon.rb', line 318 def process_label @process_label end |
#queues ⇒ Object
Returns the value of attribute queues.
320 321 322 |
# File 'lib/qs/daemon.rb', line 320 def queues @queues end |
#worker_shutdown_procs ⇒ Object (readonly)
Returns the value of attribute worker_shutdown_procs.
321 322 323 |
# File 'lib/qs/daemon.rb', line 321 def worker_shutdown_procs @worker_shutdown_procs end |
#worker_sleep_procs ⇒ Object (readonly)
Returns the value of attribute worker_sleep_procs.
322 323 324 |
# File 'lib/qs/daemon.rb', line 322 def worker_sleep_procs @worker_sleep_procs end |
#worker_start_procs ⇒ Object (readonly)
Returns the value of attribute worker_start_procs.
321 322 323 |
# File 'lib/qs/daemon.rb', line 321 def worker_start_procs @worker_start_procs end |
#worker_wakeup_procs ⇒ Object (readonly)
Returns the value of attribute worker_wakeup_procs.
322 323 324 |
# File 'lib/qs/daemon.rb', line 322 def worker_wakeup_procs @worker_wakeup_procs end |
Instance Method Details
#routes ⇒ Object
334 335 336 |
# File 'lib/qs/daemon.rb', line 334 def routes @queues.map(&:routes).flatten end |
#to_hash ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/qs/daemon.rb', line 338 def to_hash super.merge({ :process_label => self.process_label, :error_procs => self.error_procs, :worker_start_procs => self.worker_start_procs, :worker_shutdown_procs => self.worker_shutdown_procs, :worker_sleep_procs => self.worker_sleep_procs, :worker_wakeup_procs => self.worker_wakeup_procs, :routes => self.routes, :queue_redis_keys => self.queues.map(&:redis_key) }) end |
#valid? ⇒ Boolean
351 352 353 |
# File 'lib/qs/daemon.rb', line 351 def valid? !!@valid end |
#validate! ⇒ Object
355 356 357 358 359 360 361 362 363 |
# File 'lib/qs/daemon.rb', line 355 def validate! return @valid if !@valid.nil? self.init_procs.each(&:call) if self.queues.empty? || !self.required_set? raise InvalidError, "a name and queue must be configured" end self.routes.each(&:validate!) @valid = true end |