lib/ruby_skynet/zookeeper/registry.rb in ruby_skynet-1.0.0 vs lib/ruby_skynet/zookeeper/registry.rb in ruby_skynet-1.1.0
- old
+ new
@@ -32,11 +32,14 @@
# Root key to load and then monitor for changes
# It is not recommended to set the root to "/" as it will generate
# significant traffic since it will also monitor ZooKeeper Admin changes
# Mandatory
#
- # :zookeeper [Hash|ZooKeeper]
+ # :ephemeral [Boolean]
+ # All set operations of non-nil values will result in ephemeral nodes.
+ #
+ # :registry [Hash|ZooKeeper]
# ZooKeeper configuration information, or an existing
# ZooKeeper ( ZooKeeper client) instance
#
# :servers [Array of String]
# Array of URL's of ZooKeeper servers to connect to with port numbers
@@ -85,10 +88,13 @@
# Allow the serializer and deserializer implementations to be replaced
@serializer = params.delete(:serializer) || RubySkynet::Zookeeper::Json::Serializer
@deserializer = params.delete(:deserializer) || RubySkynet::Zookeeper::Json::Deserializer
+ @ephemeral = params.delete(:ephemeral)
+ @ephemeral = false if @ephemeral.nil?
+
# Generate warning log entries for any unknown configuration options
params.each_pair {|k,v| logger.warn "Ignoring unknown configuration option: #{k}"}
# Hash with Array values containing the list of children for each node, if any
@children = ThreadSafe::Hash.new
@@ -204,11 +210,11 @@
# The key that was created
# Supplying a key of '*' means all paths
# Default: '*'
#
# value
- # New value from doozer
+ # New value from the registry
#
# version
# The version number of this node
#
# Example:
@@ -228,16 +234,16 @@
# block
# The block to be called
#
# Parameters passed to the block:
# key
- # The key that was updated in doozer
+ # The key that was updated in the registry
# Supplying a key of '*' means all paths
# Default: '*'
#
# value
- # New value from doozer
+ # New value from the registry
#
# version
# The version number of this node
#
# Example:
@@ -257,11 +263,11 @@
# block
# The block to be called
#
# Parameters passed to the block:
# key
- # The key that was deleted from doozer
+ # The key that was deleted from the registry
# Supplying a key of '*' means all paths
# Default: '*'
#
# Example:
# registry.on_delete do |key, revision|
@@ -312,10 +318,10 @@
path << "/#{p}"
# Ignore errors since it may already exist
@zookeeper.create(:path => path)
end
if value
- @zookeeper.create(:path => full_path, :data => value)
+ @zookeeper.create(:path => full_path, :data => value, :ephemeral => @ephemeral)
else
@zookeeper.create(:path => full_path)
end
end
\ No newline at end of file