Class: Cellect::NodeSet
- Inherits:
-
Object
- Object
- Cellect::NodeSet
- Includes:
- Celluloid
- Defined in:
- lib/cellect/node_set.rb
Direct Known Subclasses
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
A new instance of NodeSet.
- #initialize_zk ⇒ Object
- #ready? ⇒ Boolean
Constructor Details
#initialize(zk_url = nil) ⇒ NodeSet
10 11 12 13 14 |
# File 'lib/cellect/node_set.rb', line 10 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
16 17 18 19 20 21 22 23 |
# File 'lib/cellect/node_set.rb', line 16 def initialize_zk # don't let ZK hang the thread, just retry connection on restart Timeout::timeout(5) do self.zk = ZK.new zk_url, chroot: '/cellect' end setup self.state = :ready end |
#ready? ⇒ Boolean
25 26 27 |
# File 'lib/cellect/node_set.rb', line 25 def ready? state == :ready end |