Commit c8153fcf authored by John E. Vincent's avatar John E. Vincent

more modularization on agent framework

parent c546fc73
require 'rubygems'
require File.join('.', 'lib','noah')
## Uncomment the following to hardcode a redis url
ENV['REDIS_URL'] = "redis://localhost:6379/1"
ENV['REDIS_URL'] = "redis://localhost:6379/0"
noah = Noah::App.new
run noah
......@@ -9,9 +9,6 @@ module Noah
class Agent
include EM::Deferrable
Noah::Agents::HttpAgent.register
Noah::Agents::DummyAgent.register
@@watchers = Noah::Watcher.watch_list
@@agents = Noah::Watchers.agents
......
require 'logger'
require 'logger'
module Noah::Agents
module Base
class << self
include EM::Deferrable
PREFIX = "base"
NAME = "base-agent"
end
def self.included(base)
Noah::Watchers.register_agent(base)
end
end
end
require File.join(File.dirname(__FILE__), 'base_agent')
module Noah::Agents
class DummyAgent
include EM::Deferrable
include Noah::Agents::Base
PREFIX = "dummy"
NAME = "dummy"
def self.register
Noah::Watchers.register_agent(self)
end
def self.notify(event, message, watch_list)
logger = LOGGER
logger.info("#{NAME}: Worker initiated")
......@@ -21,8 +19,8 @@ module Noah::Agents
logger.info("#{NAME}: Sending message to: #{ep} for pattern: #{p}")
logger.debug("#{NAME}: message received: #{message}")
end
iter.next
end
iter.next
end
end
......
require 'logger'
require File.join(File.dirname(__FILE__), 'base_agent')
module Noah::Agents
class HttpAgent
include EM::Deferrable
include Noah::Agents::Base
PREFIX = "http"
NAME = "http"
def self.register
Noah::Watchers.register_agent(self)
end
def self.notify(event, message, watch_list)
logger = LOGGER
logger.info("#{NAME}: Worker initiated")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment