Module: HotPotato::AppTask
Overview
AppTasks are the controllers in the framework. The Supervisor (See below) is responsible for starting AppTasks. There are three types: Faucets, Workers, and Sinks.
Constant Summary collapse
- HEARTBEAT_INTERVAL =
20
- HEARTBEAT_EXPIRE =
30
- MESSAGE_COUNT_EXPIRE =
600
Constants included from Core
Instance Method Summary collapse
-
#count_message_in ⇒ Object
Used to keep AppTask statistics when a message is received.
-
#count_message_out ⇒ Object
Used to keep AppTask statistics when a message is sent.
-
#start_heartbeat_service ⇒ Object
Starts the HeartBeat service to maintain the process id table.
Methods included from Core
#acquire_lock, #config, #log, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat
Instance Method Details
#count_message_in ⇒ Object
Used to keep AppTask statistics when a message is received.
16 17 18 19 |
# File 'lib/hot_potato/app_task.rb', line 16 def stat.incr "hotpotato.counter.apptask.#{Socket.gethostname}.#{self.class.name}.#{Process.pid}.messages_in" stat.expire "hotpotato.counter.apptask.#{Socket.gethostname}.#{self.class.name}.#{Process.pid}.messages_in", MESSAGE_COUNT_EXPIRE end |
#count_message_out ⇒ Object
Used to keep AppTask statistics when a message is sent.
22 23 24 25 |
# File 'lib/hot_potato/app_task.rb', line 22 def stat.incr "hotpotato.counter.apptask.#{Socket.gethostname}.#{self.class.name}.#{Process.pid}.messages_out" stat.expire "hotpotato.counter.apptask.#{Socket.gethostname}.#{self.class.name}.#{Process.pid}.messages_out", MESSAGE_COUNT_EXPIRE end |
#start_heartbeat_service ⇒ Object
Starts the HeartBeat service to maintain the process id table.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hot_potato/app_task.rb', line 28 def start_heartbeat_service ati = AppTaskInfo.new(:classname => self.class.name) stat.set ati.key, ati.to_json, HEARTBEAT_EXPIRE Thread.new do log.info "Thread created for AppTask [Heartbeat]" loop do ati.touch stat.set ati.key, ati.to_json, HEARTBEAT_EXPIRE sleep HEARTBEAT_INTERVAL end end end |