Class: HotPotato::Worker
- Inherits:
-
Object
- Object
- HotPotato::Worker
- Includes:
- AppTask
- Defined in:
- lib/hot_potato/worker.rb
Overview
Workers manipulate data from other workers or faucets. Examples include: Calculate Scores, Merge Data, and Filter Data. Each worker is a ruby file in the app directory that extends HotPotato::Worker and implements the perform(message) method. For each message the worker wants to send to the next AppTask, the send_message method should be called.
class Influencer < HotPotato::Worker
def perform()
["influence"] = rand(100)
end
end
Direct Known Subclasses
Constant Summary
Constants included from AppTask
AppTask::HEARTBEAT_EXPIRE, AppTask::HEARTBEAT_INTERVAL, AppTask::MESSAGE_COUNT_EXPIRE
Constants included from Core
Instance Method Summary collapse
Methods included from AppTask
#count_message_in, #count_message_out, #start_heartbeat_service
Methods included from Core
#acquire_lock, #config, #log, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat
Instance Method Details
#send_message(m) ⇒ Object
33 34 35 36 |
# File 'lib/hot_potato/worker.rb', line 33 def (m) queue_inject @queue_out, m end |
#start(queue_in) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hot_potato/worker.rb', line 20 def start(queue_in) @queue_out = underscore(self.class.name.to_sym) if !self.respond_to?('perform') log.error "The Worker #{self.class.name} does not implement a perform method." exit 1 end start_heartbeat_service queue_subscribe(queue_in) do |m| perform m end end |