class Syncrony::Observer
Attributes
running[RW]
Public Class Methods
new(client, path)
click to toggle source
# File lib/syncrony/observer.rb, line 9 def initialize(client, path) @client = client @path = path @running = true end
Public Instance Methods
cancel()
click to toggle source
# File lib/syncrony/observer.rb, line 37 def cancel @running = false end
run() { |value, path, info| ... }
click to toggle source
# File lib/syncrony/observer.rb, line 15 def run(&handler) begin info = @client.get(@path) value = info.value index = info.etcd_index rescue Etcd::KeyNotFound info = nil value = nil index = nil end yield value, @path, info while @running watch = @client.watch(@path, :index => index ? index + 1 : nil) if @running index = watch.etcd_index yield watch.value, @path, watch end end end