Should streams.getMessage return null instead of throwing when no message is found? #628
Answered
by
aricart
StrangeBytesDev
asked this question in
Ideas
-
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.
Answered by
aricart
Oct 30, 2023
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.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
aricart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/nats-io/nats.deno/issues/629