travis-ci
354 of 354 new or added lines in 10 files covered. (100.0%)
413 of 446 relevant lines covered (92.6%)
37.72 hits per line
|
module Etcd |
4✔ |
2 |
# @private
|
|
|
class Observer |
4✔ |
|
def initialize(client, prefix, handler) |
4✔ |
|
@client = client
|
12✔ |
|
@prefix = prefix
|
12✔ |
|
@handler = handler
|
12✔ |
8 |
end
|
|
9 |
|
|
|
def run |
4✔ |
|
@running = true |
12✔ |
|
index = nil
|
12✔ |
|
@thread = Thread.start do |
12✔ |
|
while @running |
12✔ |
|
@client.watch(@prefix, index: index) do |value, key, info| |
24✔ |
|
if @running |
24✔ |
|
index = info[:index]
|
24✔ |
|
@handler.call(value, key, info)
|
24✔ |
19 |
end
|
|
20 |
end
|
|
21 |
end
|
|
22 |
end
|
|
|
self
|
12✔ |
24 |
end
|
|
25 |
|
|
|
def cancel |
4✔ |
|
@running = false |
12✔ |
|
self
|
12✔ |
29 |
end
|
|
30 |
|
|
|
def join |
4✔ |
|
@thread.join
|
12✔ |
|
self
|
× |
34 |
end
|
|
35 |
end
|
|
36 |
end
|