Is it possible to avoid JS.API.STREAM.NAMES request during kv.watch? #389
-
Hello! ` $JS.API.INFO $JS.API.STREAM.INFO.ALICE $JS.API.CONSUMER.CREATE.ALICE But during kv.watch() and jetStream.subscribe() client makes JS.API.STREAM.NAMES request. There is a "stream" option in JetStreamClientImpl.subscribe (source) method. With that option client doesn't make additional request to find stream. But there's no way to pass that option from kv.watch() What should I do? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Unfortunately, Here's an example https://github.com/nats-io/nats.deno/blob/main/tests/kv_test.ts#L1474 |
Beta Was this translation helpful? Give feedback.
Unfortunately,
watch()
creates a consumer under the covers, which then matches the stream by looking at the subject, thus the call to list the streams, so that means that you cannot really bind to the consumer to observe changes. Streams in general now have arepublish
option that allows mapping messages, this means that you can use core NATS to learn if there was an update to the KV - of course, this will only work if the client is listening, but on startup, you can learn the current value and then respond to the changes. You can then allow the client to subscribe to the specific keys you want them to be able to observe.Here's an example https://github.com/nats-io/nats.deno/blob/main/te…