Add option to watch only changed keys
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
This was discussed before in issue #410, and with @mfischer-zd here: https://groups.google.com/forum/#!topic/consul-tool/Axow65BtSuY
If we change the behaviour to be "watch only keys with new UpdateIndex", then it is possible by just filtering in the endpoint code.
Reading through the code, here
https://github.com/hashicorp/consul/blob/master/consul/kvs_endpoint.go#L151
and here
https://github.com/hashicorp/consul/blob/master/consul/kvs_endpoint.go#L191
we see that in both cases, the result is filtered by applying the ACL. What if we simply add options and code here to filter out entries or keys that have an old ModifyIndex. That way, we effectively get values that have been updated.
This should be a relatively simple code change.
A more efficient way would be to also pass this option into the state functions so that only the updated entries are returned, but that is just an optimisation.
My use case is to let a client hold an in-memory replica of a set of KVs, allowing a local scan/query through the values. This would be possible by first listing all entries with a prefix, and then subsequently doing a blocking pathprefix get with a `?index=N&updates_only` option.
Contributor guide
Assessment
This issue has not been assessed yet.