KV ResumeAtRevision option for watches
mtmk opened this issue ยท 3 comments
@mtmk as per slack conversation, I'll like to give this one a shot.
Initial idea:
NatsKvOpts.cs
Would add ResumeAtRevision int prop to NatsKVWatchOpts (document it to be "The revision to start from, if set to 0 (default) this will be ignored"
https://github.com/nats-io/nats.net.v2/blob/dcfaac12777ba1d6e873e34199b3595f816319e0/src/NATS.Client.KeyValueStore/NatsKVOpts.cs#L43
NatsKVWatcher.cs
It's using the _sequenceStream here https://github.com/nats-io/nats.net.v2/blob/dcfaac12777ba1d6e873e34199b3595f816319e0/src/NATS.Client.KeyValueStore/Internal/NatsKVWatcher.cs#L353
And I was thinking about setting _sequenceStream = opts.ResumeAtRevision here https://github.com/nats-io/nats.net.v2/blob/main/src/NATS.Client.KeyValueStore/Internal/NatsKVWatcher.cs#L78
@niklasfp looking at this a bit closer I think it's good. Setting the _sequenceStream = opts.ResumeAtRevision in NatsKVWatcher.ctor should work since it will treacle down to the consumer create request down below and also should be updated as expected on reconnects. feel free to open a PR when you're ready and have time. thank you ๐ฏ
@niklasfp looking at this a bit closer I think it's good. Setting the _sequenceStream = opts.ResumeAtRevision in NatsKVWatcher.ctor should work since it will treacle down to the consumer create request down below and also should be updated as expected on reconnects. feel free to open a PR when you're ready and have time. thank you ๐ฏ
For future reference and history, setting the sequence in the ctor was not an option because of the way watchers gets re-created.