class Qs::DaemonData

Attributes

debug[R]
dwp_logger[R]
error_procs[R]
logger[R]
name[R]

The daemon uses this to “compile” the common configuration data used by the daemon instances, error handlers and routes. The goal here is to provide these with a simplified interface with the minimal data needed and to decouple the configuration from each thing that needs its data.

num_workers[R]
pid_file[R]

The daemon uses this to “compile” the common configuration data used by the daemon instances, error handlers and routes. The goal here is to provide these with a simplified interface with the minimal data needed and to decouple the configuration from each thing that needs its data.

process_label[R]
queue_redis_keys[R]
routes[R]
shutdown_timeout[R]

The daemon uses this to “compile” the common configuration data used by the daemon instances, error handlers and routes. The goal here is to provide these with a simplified interface with the minimal data needed and to decouple the configuration from each thing that needs its data.

verbose_logging[R]
worker_class[R]
worker_params[R]

Public Class Methods

new(args = nil) click to toggle source
# File lib/qs/daemon_data.rb, line 16
def initialize(args = nil)
  args ||= {}
  @name     = args[:name]
  @pid_file = args[:pid_file]

  @shutdown_timeout = args[:shutdown_timeout]

  @worker_class     = args[:worker_class]
  @worker_params    = args[:worker_params] || {}
  @num_workers      = args[:num_workers]
  @error_procs      = args[:error_procs] || []
  @logger           = args[:logger]
  @queue_redis_keys = (args[:queues] || []).map(&:redis_key)

  @verbose_logging = !!args[:verbose_logging]

  @debug      = !ENV['QS_DEBUG'].to_s.empty?
  @dwp_logger = @logger if @debug
  @routes     = build_routes(args[:routes] || [])

  @process_label = !(v = ENV['QS_PROCESS_LABEL'].to_s).empty? ? v : @name
end

Public Instance Methods

route_for(route_id) click to toggle source
# File lib/qs/daemon_data.rb, line 39
def route_for(route_id)
  @routes[route_id] || raise(NotFoundError, "unknown message '#{route_id}'")
end

Private Instance Methods

build_routes(routes) click to toggle source
# File lib/qs/daemon_data.rb, line 45
def build_routes(routes)
  routes.inject({}){ |h, route| h.merge(route.id => route) }
end