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

ephemeral node support - backend api

parent 4375abb6
......@@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), '..','lib','noah','watcher')
class StdoutWatcher < Noah::Watcher
redis_host "redis://127.0.0.1:6379/0"
pattern "noah.configuration.redis_server.update"
pattern "//noah/configuration/redis_server.*"
destination Proc.new {|x| puts x}
run!
end
......@@ -10,7 +10,7 @@ module Noah
model.send :include, Ohm::ExtraValidations
model.after :save, :notify_via_redis_save
model.after :create, :notify_via_redis_create
#model.after :create, :notify_via_redis_create
model.after :update, :notify_via_redis_update
model.before :delete, :stash_name
model.after :delete, :notify_via_redis_delete
......@@ -44,7 +44,7 @@ module Noah
protected
def patternize_me
"noah.#{self.class_to_lower}.#{name}"
"//noah/#{self.class_to_lower}/#{name.gsub(/^\//,'')}"
end
def stash_name
@deleted_name = self.name
......@@ -69,7 +69,7 @@ module Noah
#pub_category = "#{db}:noah.#{self.class.to_s}[#{name}].#{meth}"
pub_category = "#{self.patternize_me}.#{meth}"
Ohm.redis.publish(pub_category, self.to_hash.merge({"action" => meth, "pubcategory" => pub_category}).to_json)
# self.method_defined? "#{meth}_hook".to_sym
self.send("#{meth}_hook".to_sym) unless self.protected_methods.member?("#{meth}_hook".to_sym) == false
end
end
end
......
......@@ -17,6 +17,9 @@ module Noah
@name = path
end
protected
def save_hook
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Using the Ephemeral Model", :reset_redis => true do
before(:all) do
@edata = {:path => "//noah/foo/bar/baz", :data => "some_value"}
@emissing_path = @edata.reject {|x| x == :path}
@emissing_data = @edata.reject {|x| x == :data}
@good_ephemeral = Noah::Ephemeral.new(@edata)
@missing_path = Noah::Ephemeral.new(@emissing_path)
@missing_data = Noah::Ephemeral.new(@emissing_data)
end
before(:each) do
Ohm.redis.flushdb
end
after(:each) do
Ohm.redis.flushdb
end
describe "should" do
it "create a new Noah::Ephemeral" do
@good_ephemeral.valid?.should == true
@good_ephemeral.save
b = Noah::Ephemeral.find(:path => @edata[:path]).first
b.should == @good_ephemeral
end
it "create a new Noah::Ephemeral with missing data"
it "update an existing Noah::Ephemeral"
it "delete an existing Noah::Ephemeral"
end
describe "should not" do
it "create a new Noah::Ephemeral with missing path"
end
end
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