Class: AppTaskInfo
Constant Summary
HotPotato::Core::CONFIG_PATH
Class Method Summary
collapse
Instance Method Summary
collapse
#acquire_lock, #config, #log, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat
Constructor Details
#initialize(options = {}) ⇒ AppTaskInfo
Returns a new instance of AppTaskInfo.
7
8
9
10
11
12
13
14
|
# File 'lib/hot_potato/app_task_info.rb', line 7
def initialize(options = {})
@data = {}
@data[:started_at] = options[:started_at] || Time.now
@data[:updated_at] = options[:updated_at] || @data[:started_at]
@data[:hostname] = options[:hostname] || Socket.gethostname
@data[:classname] = options[:classname] || "AppTask"
@data[:pid] = options[:pid] || Process.pid
end
|
Class Method Details
.json_create(o) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/hot_potato/app_task_info.rb', line 70
def self.json_create(o)
options = {}
options[:started_at] = o["started_at"]
options[:updated_at] = o["updated_at"]
options[:pid] = o["pid"]
options[:classname] = o["classname"]
options[:hostname] = o["hostname"]
new options
end
|
Instance Method Details
#classname ⇒ Object
30
31
32
|
# File 'lib/hot_potato/app_task_info.rb', line 30
def classname
@data[:classname]
end
|
#hostname ⇒ Object
34
35
36
|
# File 'lib/hot_potato/app_task_info.rb', line 34
def hostname
@data[:hostname]
end
|
#key ⇒ Object
16
17
18
|
# File 'lib/hot_potato/app_task_info.rb', line 16
def key
"hotpotato.apptask.#{@data[:hostname]}.#{@data[:classname]}.#{@data[:pid]}"
end
|
#pid ⇒ Object
46
47
48
|
# File 'lib/hot_potato/app_task_info.rb', line 46
def pid
@data[:pid].to_i
end
|
#requests_in ⇒ Object
38
39
40
|
# File 'lib/hot_potato/app_task_info.rb', line 38
def requests_in
stat.get("hotpotato.counter.apptask.#{@data[:hostname]}.#{@data[:classname]}.#{@data[:pid]}.messages_in") || 0
end
|
#requests_out ⇒ Object
42
43
44
|
# File 'lib/hot_potato/app_task_info.rb', line 42
def requests_out
stat.get("hotpotato.counter.apptask.#{@data[:hostname]}.#{@data[:classname]}.#{@data[:pid]}.messages_out") || 0
end
|
#started_at ⇒ Object
50
51
52
53
|
# File 'lib/hot_potato/app_task_info.rb', line 50
def started_at
return nil unless @data[:started_at]
DateTime.parse(@data[:started_at])
end
|
#to_json(*a) ⇒ Object
64
65
66
67
68
|
# File 'lib/hot_potato/app_task_info.rb', line 64
def to_json(*a)
result = @data
result["json_class"] = self.class.name
result.to_json(*a)
end
|
#to_s ⇒ Object
20
21
22
|
# File 'lib/hot_potato/app_task_info.rb', line 20
def to_s
@data.to_s
end
|
#touch ⇒ Object
60
61
62
|
# File 'lib/hot_potato/app_task_info.rb', line 60
def touch
@data[:updated_at] = Time.now
end
|
#type ⇒ Object
24
25
26
27
28
|
# File 'lib/hot_potato/app_task_info.rb', line 24
def type
return "Faucet" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Faucet)
return "Worker" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Worker)
return "Sink" if Kernel.const_get(@data[:classname]).ancestors.include?(HotPotato::Sink)
end
|
#updated_at ⇒ Object
55
56
57
58
|
# File 'lib/hot_potato/app_task_info.rb', line 55
def updated_at
return nil unless @data[:updated_at]
DateTime.parse(@data[:updated_at])
end
|