Class: RedisRing::ZookeeperObserver
- Inherits:
-
Object
- Object
- RedisRing::ZookeeperObserver
- Includes:
- BackgroundThread
- Defined in:
- lib/redis_ring/zookeeper_observer.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
readonly
Returns the value of attribute master.
-
#slave ⇒ Object
readonly
Returns the value of attribute slave.
-
#zookeeper_connection ⇒ Object
readonly
Returns the value of attribute zookeeper_connection.
Instance Method Summary collapse
- #do_work ⇒ Object
-
#initialize(zookeeper_connection, master, slave) ⇒ ZookeeperObserver
constructor
A new instance of ZookeeperObserver.
Methods included from BackgroundThread
#after_halt, #before_run, #continue_running?, #halt, #run
Constructor Details
#initialize(zookeeper_connection, master, slave) ⇒ ZookeeperObserver
Returns a new instance of ZookeeperObserver.
9 10 11 12 13 14 |
# File 'lib/redis_ring/zookeeper_observer.rb', line 9 def initialize(zookeeper_connection, master, slave) @zookeeper_connection = zookeeper_connection @master = master @slave = slave @current_master = nil end |
Instance Attribute Details
#master ⇒ Object (readonly)
Returns the value of attribute master.
7 8 9 |
# File 'lib/redis_ring/zookeeper_observer.rb', line 7 def master @master end |
#slave ⇒ Object (readonly)
Returns the value of attribute slave.
7 8 9 |
# File 'lib/redis_ring/zookeeper_observer.rb', line 7 def slave @slave end |
#zookeeper_connection ⇒ Object (readonly)
Returns the value of attribute zookeeper_connection.
7 8 9 |
# File 'lib/redis_ring/zookeeper_observer.rb', line 7 def zookeeper_connection @zookeeper_connection end |
Instance Method Details
#do_work ⇒ Object
16 17 18 19 |
# File 'lib/redis_ring/zookeeper_observer.rb', line 16 def do_work on_node_list_changed(zookeeper_connection.nodes) if zookeeper_connection.nodes_changed? sleep(0.1) end |