mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3: support watcher ranges
This commit is contained in:
parent
c0eac7ab72
commit
eb327c690b
@ -157,6 +157,20 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestWatchRange tests watcher creates ranges
|
||||||
|
func TestWatchRange(t *testing.T) {
|
||||||
|
runWatchTest(t, testWatchReconnInit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testWatchRange(t *testing.T, wctx *watchctx) {
|
||||||
|
if wctx.ch = wctx.w.Watch(context.TODO(), "a", clientv3.WithRange("c")); wctx.ch == nil {
|
||||||
|
t.Fatalf("expected non-nil channel")
|
||||||
|
}
|
||||||
|
putAndWatch(t, wctx, "a", "a")
|
||||||
|
putAndWatch(t, wctx, "b", "b")
|
||||||
|
putAndWatch(t, wctx, "bar", "bar")
|
||||||
|
}
|
||||||
|
|
||||||
// TestWatchReconnRequest tests the send failure path when requesting a watcher.
|
// TestWatchReconnRequest tests the send failure path when requesting a watcher.
|
||||||
func TestWatchReconnRequest(t *testing.T) {
|
func TestWatchReconnRequest(t *testing.T) {
|
||||||
runWatchTest(t, testWatchReconnRequest)
|
runWatchTest(t, testWatchReconnRequest)
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
package clientv3
|
package clientv3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||||
"github.com/coreos/etcd/lease"
|
"github.com/coreos/etcd/lease"
|
||||||
)
|
)
|
||||||
@ -119,8 +117,6 @@ func opWatch(key string, opts ...OpOption) Op {
|
|||||||
ret := Op{t: tRange, key: []byte(key)}
|
ret := Op{t: tRange, key: []byte(key)}
|
||||||
ret.applyOpts(opts)
|
ret.applyOpts(opts)
|
||||||
switch {
|
switch {
|
||||||
case ret.end != nil && !reflect.DeepEqual(ret.end, getPrefix(ret.key)):
|
|
||||||
panic("only supports single keys or prefixes")
|
|
||||||
case ret.leaseID != 0:
|
case ret.leaseID != 0:
|
||||||
panic("unexpected lease in watch")
|
panic("unexpected lease in watch")
|
||||||
case ret.limit != 0:
|
case ret.limit != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user