Class: HotPotato::Faucet
- Inherits:
-
Object
- Object
- HotPotato::Faucet
- Includes:
- AppTask
- Defined in:
- lib/hot_potato/faucet.rb
Overview
Faucets inject data into the system. Examples include: Twitter Reader, SMTP, and Tail Log File. Each faucet is a ruby file in the app directory that extends HotPotato::Faucet and implements the perform method. For each message received, the method should call the send_message to send it to the next AppTask.
class TwitterFaucet < HotPotato::Faucet
def perform
TweetStream::Client.new("user", "secret").sample do |s|
= {}
["username"] = s.user.screen_name
["text"] = s.text
end
end
end
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
34 35 36 37 |
# File 'lib/hot_potato/faucet.rb', line 34 def (m) queue_inject @queue_out, m end |
#start ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/hot_potato/faucet.rb', line 24 def start @queue_out = underscore(self.class.name.to_sym) if self.respond_to?('perform') start_heartbeat_service perform else log.error "The Faucet #{self.class.name} does not implement a perform method." end end |