These are chat archives for spring-cloud/spring-cloud

19th
Feb 2019
Spencer Gibb
@spencergibb
Feb 19 14:55
@jmax01 no
Johannes Edmeier
@joshiste
Feb 19 19:20
When looking at https://github.com/spring-cloud/spring-cloud-consul/blob/master/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulCatalogWatch.java the HeartBeatEvent is only published when a new service appears, but not when an underlying node of an existing service (dis-)appears. Is this on purpose? I'd expect that to happen (as it is with eureka). Currently Spring Boot Admin is relying on this and currently new nodes do not show up when using consul discovery...
Spencer Gibb
@spencergibb
Feb 19 19:24
I don't think it is on purpose. IIRC it watches the consulIndex. Does that not change if a service goes away?
Johannes Edmeier
@joshiste
Feb 19 22:05
haven't tested it but in my understanding the index is per resource and since nodes are a different resource than services the index doesn't update
Spencer Gibb
@spencergibb
Feb 19 22:13
If the consul index doesn't change we'd have to keep a cache of services and compare each time
and maintain a local atomic integer that we increment with each response
Johannes Edmeier
@joshiste
Feb 19 22:31

My guess would be just to query a different resource (use getCatalogNodes instead of getCatalogServices) . If I get https://www.consul.io/api/index.html right, the index should change when the nodes change

Endpoints that support blocking queries return an HTTP header named X-Consul-Index. This is a unique identifier representing the current state of the requested resource.