From 0e7fd4a37cbc65106f67d93d52a7d5db8c20be2b Mon Sep 17 00:00:00 2001 From: darasion Date: Sat, 15 Apr 2017 22:31:50 +0800 Subject: [PATCH] clientv3/namespace: fix incorrect watching prefix-end using "abc" will watch the wrong range when WithPrefix() specified. --- clientv3/namespace/doc.go | 2 +- clientv3/namespace/watch.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clientv3/namespace/doc.go b/clientv3/namespace/doc.go index c3ce14b9d4e..3f883320fcc 100644 --- a/clientv3/namespace/doc.go +++ b/clientv3/namespace/doc.go @@ -27,7 +27,7 @@ // unprefixedKV := cli.KV // cli.KV = namespace.NewKV(cli.KV, "my-prefix/") // cli.Watcher = namespace.NewWatcher(cli.Watcher, "my-prefix/") -// cli.Leases = namespace.NewLease(cli.Lease, "my-prefix/") +// cli.Lease = namespace.NewLease(cli.Lease, "my-prefix/") // // Now calls using 'cli' will namespace / prefix all keys with "my-prefix/": // diff --git a/clientv3/namespace/watch.go b/clientv3/namespace/watch.go index 5697f449684..6257e296829 100644 --- a/clientv3/namespace/watch.go +++ b/clientv3/namespace/watch.go @@ -40,7 +40,7 @@ func NewWatcher(w clientv3.Watcher, prefix string) clientv3.Watcher { func (w *watcherPrefix) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan { // since OpOption is opaque, determine range for prefixing through an OpGet - op := clientv3.OpGet("abc", opts...) + op := clientv3.OpGet(key, opts...) end := op.RangeBytes() pfxBegin, pfxEnd := prefixInterval(w.pfx, []byte(key), end) if pfxEnd != nil {