I'm trying to use Consul's Key-Value API to pass a JSON configuration to an app running in one of my containers. It works great, but the API does not provide any pub-sub functionality (just read/write/delete) for a key.
So far, I managed to artificially compensate by using the Watch feature to restart the container whenever the key changes, but that leaves me with the need to
Is there any programatic way (other than polling every x seconds) to get notified of a key change in Consul, or should I just back away from this solution, and move to Redis?
After a quick look at consul's sources, it seems that the "watch" is a simple periodic pull. You could implement something similar in your code to achieve this.
Periodic run of the watcher: https://github.com/hashicorp/consul/blob/master/watch/plan.go#L46
KeyWatch Handler: https://github.com/hashicorp/consul/blob/master/watch/funcs.go#L29