Class: Zoology::PathCache::Watcher
- Inherits:
-
Object
- Object
- Zoology::PathCache::Watcher
show all
- Includes:
- Logging
- Defined in:
- lib/zoology/path_cache/watcher.rb
Instance Method Summary
collapse
Methods included from Logging
disable!, #logger, logger
Constructor Details
#initialize(client, path, zk_call = :get, &callback) ⇒ Watcher
Returns a new instance of Watcher.
36
37
38
39
40
41
42
43
|
# File 'lib/zoology/path_cache/watcher.rb', line 36
def initialize(client, path, zk_call = :get, &callback)
@client = client
@path = path
@zk_call = zk_call
@callback = callback
super()
end
|
Instance Method Details
#deleted ⇒ Object
63
64
65
|
# File 'lib/zoology/path_cache/watcher.rb', line 63
def deleted
call(:deleted)
end
|
#set_watch ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/zoology/path_cache/watcher.rb', line 45
def set_watch
watcher = @client.watcher_callback do |event|
set_watch if event.type != Zookeeper::ZOO_SESSION_EVENT
end
begin
req = @client.send(@zk_call, :path => @path, :watcher => watcher)
if req[:rc] == Zookeeper::ZOK
call(:update, req)
elsif req[:rc] == Zookeeper::ZNONODE
shutdown
else
not_watching
end
rescue Zookeeper::Exceptions::ContinuationTimeoutError
not_watching
end
end
|