Class: Delayed::Master::WorkerSetting

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

Constant Summary collapse

SIMPLE_CONFIGS =
[:id, :max_processes, :max_threads, :max_memory,
:min_priority, :max_priority, :sleep_delay, :read_ahead, :exit_on_complete,
:max_attempts, :max_run_time, :destroy_failed_jobs]
ARRAY_CONFIGS =
[:queues]

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ WorkerSetting

Returns a new instance of WorkerSetting.



14
15
16
17
18
19
20
# File 'lib/delayed/master/worker_setting.rb', line 14

def initialize(attrs = {})
  @queues = []
  @max_processes = 1
  @max_threads = 1
  @exit_on_complete = true
  self.attributes = attrs
end

Instance Method Details

#attributes=(attrs = {}) ⇒ Object



22
23
24
25
26
# File 'lib/delayed/master/worker_setting.rb', line 22

def attributes=(attrs = {})
  attrs.each do |key, value|
    send("#{key}=", value)
  end
end

#control(value = nil) ⇒ Object



58
59
60
61
62
# File 'lib/delayed/master/worker_setting.rb', line 58

def control(value = nil)
  warn <<-TEXT.squish
    DEPRECATION WARNING: 'control' setting was deprecated. Remove it from your config file. (#{caller[0]})
  TEXT
end

#count(value = nil) ⇒ Object



64
65
66
67
68
69
# File 'lib/delayed/master/worker_setting.rb', line 64

def count(value = nil)
  warn <<-TEXT.squish
    DEPRECATION WARNING: 'count' setting was deprecated. Use 'max_processes' instead. (#{caller[0]})
  TEXT
  max_processes value
end

#worker_infoObject



32
33
34
35
36
# File 'lib/delayed/master/worker_setting.rb', line 32

def worker_info
  strs = [worker_name]
  strs << "(#{@queues.join(', ')})" if @queues.present?
  strs.join(' ')
end

#worker_nameObject



28
29
30
# File 'lib/delayed/master/worker_setting.rb', line 28

def worker_name
  "worker[#{id}]"
end