Class: ZooMQ::Zookeeper
- Inherits:
-
Object
- Object
- ZooMQ::Zookeeper
- Defined in:
- lib/zoomq/zookeeper.rb
Defined Under Namespace
Classes: KeySpace
Instance Attribute Summary collapse
-
#globals ⇒ Object
readonly
Returns the value of attribute globals.
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
Instance Method Summary collapse
- #announce(identity) ⇒ Object
- #close ⇒ Object
-
#initialize(service_name) ⇒ Zookeeper
constructor
A new instance of Zookeeper.
- #servers ⇒ Object
- #watch(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#globals ⇒ Object (readonly)
Returns the value of attribute globals.
7 8 9 |
# File 'lib/zoomq/zookeeper.rb', line 7 def globals @globals end |
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
8 9 10 |
# File 'lib/zoomq/zookeeper.rb', line 8 def locals @locals end |
Instance Method Details
#announce(identity) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/zoomq/zookeeper.rb', line 16 def announce(identity) @locals = KeySpace.new(identity, @zk) path = "/alive/#{identity}" @zk.block_until_node_deleted(path) if @zk.exists?(path) @zk.create(path, mode: :ephemeral) end |
#close ⇒ Object
23 24 25 |
# File 'lib/zoomq/zookeeper.rb', line 23 def close @zk.close! end |
#servers ⇒ Object
32 33 34 |
# File 'lib/zoomq/zookeeper.rb', line 32 def servers @zk.children('/alive', watch: true) end |
#watch(&block) ⇒ Object
27 28 29 30 |
# File 'lib/zoomq/zookeeper.rb', line 27 def watch(&block) @zk.register('/alive', &block) servers end |