Class: Qs::DaemonData

Inherits:
Object
  • Object
show all
Defined in:
lib/qs/daemon_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ DaemonData

Returns a new instance of DaemonData.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/qs/daemon_data.rb', line 18

def initialize(args = nil)
  args ||= {}
  @name             = args[:name]
  @pid_file         = args[:pid_file]
  @min_workers      = args[:min_workers]
  @max_workers      = args[:max_workers]
  @logger           = args[:logger]
  @verbose_logging  = !!args[:verbose_logging]
  @shutdown_timeout = args[:shutdown_timeout]
  @error_procs      = args[:error_procs] || []
  @queue_redis_keys = args[:queue_redis_keys] || []
  @routes           = build_routes(args[:routes] || [])
end

Instance Attribute Details

#error_procsObject (readonly)

Returns the value of attribute error_procs.



15
16
17
# File 'lib/qs/daemon_data.rb', line 15

def error_procs
  @error_procs
end

#loggerObject (readonly)

Returns the value of attribute logger.



13
14
15
# File 'lib/qs/daemon_data.rb', line 13

def logger
  @logger
end

#max_workersObject (readonly)

Returns the value of attribute max_workers.



12
13
14
# File 'lib/qs/daemon_data.rb', line 12

def max_workers
  @max_workers
end

#min_workersObject (readonly)

Returns the value of attribute min_workers.



12
13
14
# File 'lib/qs/daemon_data.rb', line 12

def min_workers
  @min_workers
end

#nameObject (readonly)

The daemon uses this to “compile” its configuration for speed. NsOptions is relatively slow everytime an option is read. To avoid this, we read the options one time here and memoize their values. This way, we don’t pay the NsOptions overhead when reading them while handling a job.



10
11
12
# File 'lib/qs/daemon_data.rb', line 10

def name
  @name
end

#pid_fileObject (readonly)

Returns the value of attribute pid_file.



11
12
13
# File 'lib/qs/daemon_data.rb', line 11

def pid_file
  @pid_file
end

#queue_redis_keysObject (readonly)

Returns the value of attribute queue_redis_keys.



16
17
18
# File 'lib/qs/daemon_data.rb', line 16

def queue_redis_keys
  @queue_redis_keys
end

#routesObject (readonly)

Returns the value of attribute routes.



16
17
18
# File 'lib/qs/daemon_data.rb', line 16

def routes
  @routes
end

#shutdown_timeoutObject (readonly)

Returns the value of attribute shutdown_timeout.



14
15
16
# File 'lib/qs/daemon_data.rb', line 14

def shutdown_timeout
  @shutdown_timeout
end

#verbose_loggingObject (readonly)

Returns the value of attribute verbose_logging.



13
14
15
# File 'lib/qs/daemon_data.rb', line 13

def verbose_logging
  @verbose_logging
end

Instance Method Details

#route_for(name) ⇒ Object



32
33
34
# File 'lib/qs/daemon_data.rb', line 32

def route_for(name)
  @routes[name] || raise(NotFoundError, "no service named '#{name}'")
end