Skip to content

Commit

Permalink
Merge pull request #1116 from nats-io/kv-mirror-watcher
Browse files Browse the repository at this point in the history
Use BindStream for watcher so it works with mirrors.
  • Loading branch information
derekcollison committed Nov 1, 2022
2 parents 48285d7 + 416c895 commit e227e17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kv.go
Expand Up @@ -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())
}
Expand Down
5 changes: 5 additions & 0 deletions test/kv_test.go
Expand Up @@ -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)
Expand Down

0 comments on commit e227e17

Please sign in to comment.