nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
187 stars 20 forks source link

KV watch should allow option for durable consumer #75

Open aricart opened 2 years ago

aricart commented 2 years ago

If the watch is used as a reactive mechanism for updating on changes, the current implementation which notifies of 'current values', creates an issue, that every time the process starts, it gets spammed with startup values. The process could filter those updates pending some sequence/etc, but this is effectively the functionality of the durable consumer.

An option should be provided to make the watch/history consumer be durable if desired. This would allow a restarting process to trigger updates only if things changed while the process was offline.

https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-8.md

ripienaar commented 2 years ago

I'm a bit reluctant to support this in the main KV ADR because it's going to be impossible to support against any other backend and seems a bit weird to me.

I see the usecase but it feels a bit like something we should probably support as a language specific extension or something rather than something in the core feature set

scottf commented 2 years ago

Maybe this can be a store specific option. I could see in the future that there will be other store specific options, we might as well think about ways to support that. In fact Our api currently does not have a way for a type of store to be selected. Maybe we should implement something, even though the only choice will be JetStream for right now.