Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Add client support for Watches #31

Closed
ghost opened this issue Jun 18, 2015 · 5 comments
Closed

Add client support for Watches #31

ghost opened this issue Jun 18, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Jun 18, 2015

It would be great if real-time notification of config changes (KV data changes) were possible on the client-side.

I believe this concept is supported in the "raw" Consult API via watches, however I don't see that concept supported by this library.

The idea is simple:

  • Allow clients to register their own callbacks/watches with the Consul cluster
  • The callback/watch will now execute when the cluster senses a change to config data (or anything really)

The idea is to allow GOSSIP to "do its thing" and update clients in real-time, rather than forcing clients to poll.

@rickfast
Copy link
Owner

We do support this already. We actually use this concept in production. Notice the methods in the kv client and health client that accept callbacks. Although not all of the "watchable" endpoints have been implemented. The plumbing is there.

@ghost
Copy link
Author

ghost commented Jun 18, 2015

Very nice! Are these ConsulResponseCallbacks based on polling or are they actually real callbacks, as "pushed" from the Consul server?

@rickfast
Copy link
Owner

Watches are implemented using blocking queries in the HTTP API. Agents automatically make the proper API calls to watch for changes and inform a handler when the data view has updated.

The only other way I see to implement watches is with the "handler" approach, which involves giving Consul a script to execute when watched attributes change. This seems out of scope for this client.

@rickfast
Copy link
Owner

They're based on long polling. I don't see another way to implement it using the HTTP API.

@ghost
Copy link
Author

ghost commented Jun 18, 2015

Sure, ok thanks for the help here - feel free to close/delete this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant