Class: Karma::Messages::ProcessConfigUpdateMessage

Inherits:
BaseKarmap show all
Defined in:
lib/karma_messages/process_config_update_message.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#errors, #service

Instance Method Summary collapse

Methods inherited from Base

#clear_errors, #initialize, #message_type, #valid?

Constructor Details

This class inherits a constructor from Karma::Messages::Base

Instance Attribute Details

#auto_restartObject (readonly)

Returns the value of attribute auto_restart.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def auto_restart
  @auto_restart
end

#auto_startObject (readonly)

Returns the value of attribute auto_start.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def auto_start
  @auto_start
end

#cpu_quotaObject (readonly)

Returns the value of attribute cpu_quota.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def cpu_quota
  @cpu_quota
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def log_level
  @log_level
end

#max_runningObject (readonly)

Returns the value of attribute max_running.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def max_running
  @max_running
end

#memory_maxObject (readonly)

Returns the value of attribute memory_max.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def memory_max
  @memory_max
end

#min_runningObject (readonly)

Returns the value of attribute min_running.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def min_running
  @min_running
end

#notify_intervalObject (readonly)

Returns the value of attribute notify_interval.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def notify_interval
  @notify_interval
end

#num_threadsObject (readonly)

Returns the value of attribute num_threads.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def num_threads
  @num_threads
end

#push_notificationsObject (readonly)

Returns the value of attribute push_notifications.



5
6
7
# File 'lib/karma_messages/process_config_update_message.rb', line 5

def push_notifications
  @push_notifications
end

Instance Method Details

#parse(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/karma_messages/process_config_update_message.rb', line 7

def parse(params)
  super(params)

  @errors << { min_running:   'Required' } if params[:min_running].nil?
  @errors << { max_running:   'Required' } if params[:max_running].nil?
  @errors << { auto_restart:  'Required' } if params[:auto_restart].nil?
  @errors << { auto_start:    'Required' } if params[:auto_start].nil?
  @errors << { log_level:     'Required' } if params[:log_level].nil?
  @errors << { num_threads:   'Required' } if params[:num_threads].nil?

  @memory_max           = params[:memory_max]
  @cpu_quota            = params[:cpu_quota]
  @min_running          = params[:min_running]
  @max_running          = params[:max_running]
  @auto_restart         = params[:auto_restart]
  @auto_start           = params[:auto_start]
  @push_notifications   = params[:push_notifications]
  @log_level            = params[:log_level]
  @num_threads          = params[:num_threads]
  @notify_interval      = params[:notify_interval]
end

#to_configObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/karma_messages/process_config_update_message.rb', line 40

def to_config
  {
    memory_max: memory_max,
    cpu_quota: cpu_quota,
    min_running: min_running,
    max_running: max_running,
    auto_restart: auto_restart,
    auto_start: auto_start,
    push_notifications: push_notifications,
    num_threads: num_threads,
    log_level: log_level,
    notify_interval: notify_interval
  }
end

#to_messageObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/karma_messages/process_config_update_message.rb', line 29

def to_message
  ret = super
  ret.merge!({ min_running: @min_running, max_running: @max_running, auto_restart: @auto_restart, auto_start: @auto_start })
  ret.merge!({ log_level: @log_level, num_threads: @num_threads })
  ret.merge!({ memory_max: @memory_max} ) if @memory_max.present?
  ret.merge!({ cpu_quota: @cpu_quota} ) if @cpu_quota.present?
  ret.merge!({ push_notifications: @push_notifications} ) if @push_notifications.present?
  ret.merge!({ notify_interval: @notify_interval} ) if @notify_interval.present?
  ret
end