Class: Delayed::Master::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/delayed/master/config.rb

Constant Summary collapse

SIMPLE_CONFIGS =
[:daemon, :working_directory, :log_file, :log_level, :pid_file,
:monitor_interval, :polling_interval, :databases]
CALLBACK_CONFIGS =
[:before_fork, :after_fork,
:before_monitor, :after_monitor, :around_monitor,
:before_polling, :after_polling, :around_polling]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ Config



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/delayed/master/config.rb', line 18

def initialize(file = nil)
  @daemon = false
  @working_directory = Dir.pwd
  @pid_file = "#{@working_directory}/tmp/pids/delayed_job_master.pid"
  @log_file = "#{@working_directory}/log/delayed_job_master.log"
  @log_level = :info
  @monitor_interval = 5
  @polling_interval = 30
  @databases = []
  CALLBACK_CONFIGS.each do |name|
    send("#{name}=", [])
  end
  @workers = []
  read(file) if file
end

Instance Attribute Details

#workersObject (readonly)

Returns the value of attribute workers.



16
17
18
# File 'lib/delayed/master/config.rb', line 16

def workers
  @workers
end

Instance Method Details

#abstract_textsObject



76
77
78
79
80
81
82
83
84
85
# File 'lib/delayed/master/config.rb', line 76

def abstract_texts
  texts = []
  texts << "databases: #{@databases.join(', ')}" if @databases.present?
  texts += @workers.map do |worker|
    str = "worker[#{worker.id}]: #{worker.max_processes} processes, #{worker.max_threads} threads"
    str += " (#{worker.queues.join(', ')})" if worker.queues.present?
    str
  end
  texts
end

#add_worker {|worker| ... } ⇒ Object

Yields:

  • (worker)


42
43
44
45
46
47
# File 'lib/delayed/master/config.rb', line 42

def add_worker
  worker = WorkerSetting.new(id: @workers.size)
  yield worker if block_given?
  @workers << worker
  worker
end

#monitor_wait(value = nil) ⇒ Object



69
70
71
72
73
74
# File 'lib/delayed/master/config.rb', line 69

def monitor_wait(value = nil)
  ActiveSupport::Deprecation.warn "    deprecated 'monitor_wait' setting was used. Use 'monitor_interval' instead.\"\n  TEXT\n  @monitor_interval = @polling_interval = value\nend\n".squish

#read(file) ⇒ Object



34
35
36
# File 'lib/delayed/master/config.rb', line 34

def read(file)
  instance_eval(File.read(file), file)
end

#worker_settingsObject



38
39
40
# File 'lib/delayed/master/config.rb', line 38

def worker_settings
  @workers
end