From 416c895ab055306df6662f4d84986a7e7759c6d0 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 1 Nov 2022 14:45:39 -0700 Subject: [PATCH] Use BindStream for watcher so it works with mirrors. Signed-off-by: Derek Collison --- kv.go | 2 +- test/kv_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kv.go b/kv.go index 477a8b39d..3761a33eb 100644 --- a/kv.go +++ b/kv.go @@ -926,7 +926,7 @@ func (kv *kvs) Watch(keys string, opts ...WatchOpt) (KeyWatcher, error) { } // Used ordered consumer to deliver results. - subOpts := []SubOpt{OrderedConsumer()} + subOpts := []SubOpt{BindStream(kv.stream), OrderedConsumer()} if !o.includeHistory { subOpts = append(subOpts, DeliverLastPerSubject()) } diff --git a/test/kv_test.go b/test/kv_test.go index f916ff7e1..c668e6f12 100644 --- a/test/kv_test.go +++ b/test/kv_test.go @@ -968,6 +968,11 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { t.Fatalf("Got wrong value: %q vs %q", e.Value(), "rip") } + // Also make sure we can create a watcher on the mirror KV. + watcher, err := mkv.WatchAll() + expectOk(t, err) + defer watcher.Stop() + // Bind through leafnode connection but to origin KV. rjs, err := lnc.JetStream(nats.Domain("HUB")) expectOk(t, err)