From 2673e657e63a7913e54391f015cc7e55ab72ab12 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Wed, 21 Oct 2015 11:50:25 -0700 Subject: [PATCH 1/2] storage: fix WatchableKV interface We delete endRev from the watch functionality, so the interface needs to be fixed. --- storage/kv.go | 3 +-- storage/kv_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/kv.go b/storage/kv.go index e8250f081..c1775514e 100644 --- a/storage/kv.go +++ b/storage/kv.go @@ -97,9 +97,8 @@ type WatchableKV interface { // event history can be watched unless compacted. // If `prefix` is true, watch observes all events whose key prefix could be the given `key`. // If `startRev` <=0, watch observes events after currentRev. - // If `endRev` <=0, watch observes events until watch is cancelled. // // Canceling the watcher releases resources associated with it, so code // should always call cancel as soon as watch is done. - Watcher(key []byte, prefix bool, startRev, endRev int64) (Watcher, CancelFunc) + Watcher(key []byte, prefix bool, startRev int64) (Watcher, CancelFunc) } diff --git a/storage/kv_test.go b/storage/kv_test.go index 67e1bce7a..f0db69481 100644 --- a/storage/kv_test.go +++ b/storage/kv_test.go @@ -730,7 +730,7 @@ func TestKVSnapshot(t *testing.T) { } func TestWatchableKVWatch(t *testing.T) { - s := newWatchableStore(tmpPath) + s := WatchableKV(newWatchableStore(tmpPath)) defer cleanup(s, tmpPath) wa, cancel := s.Watcher([]byte("foo"), true, 0) From 027c073d5505e8a068169f3c843861a14995e35a Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Wed, 21 Oct 2015 14:47:52 -0700 Subject: [PATCH 2/2] storage: refine Watch comment in WatchableKV Explain explicitly how these arguments are used. --- storage/kv.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/kv.go b/storage/kv.go index c1775514e..ceec4f0cd 100644 --- a/storage/kv.go +++ b/storage/kv.go @@ -93,8 +93,9 @@ type Watcher interface { type WatchableKV interface { KV - // Watcher watches the events happening or happened in etcd. The whole - // event history can be watched unless compacted. + // Watcher watches the events happening or happened on the given key + // or key prefix from the given startRev. + // The whole event history can be watched unless compacted. // If `prefix` is true, watch observes all events whose key prefix could be the given `key`. // If `startRev` <=0, watch observes events after currentRev. //