-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add client support for Watches #19
Comments
Hi I also like use this feature but the implementation wouldn't be easy, Consul do not provide http api to register watches, currently I just adding watches by executing Consul agent commands from java Runtime.getRuntime().exec(...) so firslty we have to wait for exposing new http api methods in Consul :( |
Yes. This is the only thing that stops me from implementation |
I believe we can find those HTTP commands using a simple sniffer proxy. update: I created a simple http reverse proxy w/ logging using node.js, Check out this log :
It seems that at first, the client looks for the current value of the key, after that, it queries the same key w/ a query string parameter named "index" that returned from the last result, at this point, the HTTP request is blocking until the key is updated... update 2: Same thing happens for
(BTW, the request and responses that you see are the headers and not the body) |
It's pretty easy to implement on this client, I managed to do so without any need to modify the client. Good job @vgv and ecwid 👍 |
below are sample code based on @shanielh explanation: private static void longPolling(String serviceName){
long consulIndex = -1;
do{
QueryParams param =
QueryParams.Builder.builder()
.setIndex(consulIndex)
.build();
Response<List<HealthService>> healthyServices =
consulClient.getHealthServices(serviceName, true, param);
consulIndex = healthyServices.getConsulIndex();
List<HealthService> services = healthyServices.getValue();
for (HealthService healthyService : services) {
logger.info("Updated services info: {}", healthyService);
}
}while(true);
} |
can support watch service now? rickfast's consul-client hava a class ServiceHealthCache support watch service. |
Hi, I also started looking at this implementation and looking for watch service. Would it be implemented? |
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:
The idea is to allow GOSSIP to "do its thing" and update clients in real-time, rather than forcing clients to poll.
The text was updated successfully, but these errors were encountered: