Should streams.getMessage return null instead of throwing when no message is found? #628
-
streams.getMessage seems particularly useful to me to check if a queued task is still in the queue. Something like: const js = await nc.jetstream()
const jsm = await nc.jetstreamManager()
await jsm.streams.add({
name: 'long-running-jobs',
retention: RetentionPolicy.Workqueue,
subjects: ['long-running-jobs.*']
})
js.publish('long-running-jobs.job-10', 'hello world')
const jobPending = Boolean(await jsm.streams.getMessage('long-running-jobs', {last_by_subj: 'long-running-jobs.job-10'})) Currently, this is relatively easy to do by just using a try catch around getMessage, but it seems to me like returning null would be a little easier to work with, and makes more intuitive sense as a response. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I am going to investigate the ramifications. For KV I do exactly that, so it seems reasonable to adopt this. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/nats-io/nats.deno/issues/629 |
Beta Was this translation helpful? Give feedback.
https://github.com/nats-io/nats.deno/issues/629