Class: Cellect::NodeSet
- Inherits:
-
Object
- Object
- Cellect::NodeSet
- Includes:
- Celluloid
- Defined in:
- lib/cellect/node_set.rb
Direct Known Subclasses
Constant Summary collapse
- ConnectionError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
-
#zk ⇒ Object
Returns the value of attribute zk.
Instance Method Summary collapse
-
#initialize(zk_url = nil) ⇒ NodeSet
constructor
Sets up the node set and starts connecting to ZooKeeper.
-
#initialize_zk ⇒ Object
Connect to ZooKeeper, setup this node, and change state.
- #ready? ⇒ Boolean
Constructor Details
#initialize(zk_url = nil) ⇒ NodeSet
Sets up the node set and starts connecting to ZooKeeper
11 12 13 14 15 |
# File 'lib/cellect/node_set.rb', line 11 def initialize(zk_url = nil) @zk_url = zk_url self.state = :initializing after(0.001){ async.initialize_zk } # don't block waiting for ZK to connect end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
8 9 10 |
# File 'lib/cellect/node_set.rb', line 8 def state @state end |
#zk ⇒ Object
Returns the value of attribute zk.
8 9 10 |
# File 'lib/cellect/node_set.rb', line 8 def zk @zk end |
Instance Method Details
#initialize_zk ⇒ Object
Connect to ZooKeeper, setup this node, and change state
18 19 20 21 22 23 24 |
# File 'lib/cellect/node_set.rb', line 18 def initialize_zk Timeout::timeout(timeout_duration) do self.zk = ZK.new zk_url, chroot: '/cellect' end setup self.state = :ready end |
#ready? ⇒ Boolean
26 27 28 |
# File 'lib/cellect/node_set.rb', line 26 def ready? state == :ready end |