Class: RedisRing::ZookeeperObserver

Inherits:
Object
  • Object
show all
Includes:
BackgroundThread
Defined in:
lib/redis_ring/zookeeper_observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#masterObject (readonly)

Returns the value of attribute master.



7
8
9
# File 'lib/redis_ring/zookeeper_observer.rb', line 7

def master
  @master
end

#slaveObject (readonly)

Returns the value of attribute slave.



7
8
9
# File 'lib/redis_ring/zookeeper_observer.rb', line 7

def slave
  @slave
end

#zookeeper_connectionObject (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_workObject



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