Search in sources :

Example 6 with Event

use of com.ecwid.consul.v1.event.model.Event in project spring-cloud-consul by spring-cloud.

the class EventService method filterEvents.

/**
 * from https://github.com/hashicorp/consul/blob/master/watch/funcs.go#L169-L194 .
 * @param toFilter events to filter
 * @param lastIndex last index to pick from the list of events
 * @return filtered list of events
 */
protected List<Event> filterEvents(List<Event> toFilter, Long lastIndex) {
    List<Event> events = toFilter;
    if (lastIndex != null) {
        for (int i = 0; i < events.size(); i++) {
            Event event = events.get(i);
            Long eventIndex = event.getWaitIndex();
            if (lastIndex.equals(eventIndex)) {
                events = events.subList(i + 1, events.size());
                break;
            }
        }
    }
    return events;
}
Also used : Event(com.ecwid.consul.v1.event.model.Event)

Aggregations

Event (com.ecwid.consul.v1.event.model.Event)3 QueryParams (com.ecwid.consul.v1.QueryParams)2 List (java.util.List)2 ConsulClient (com.ecwid.consul.v1.ConsulClient)1 OperationException (com.ecwid.consul.v1.OperationException)1 EventParams (com.ecwid.consul.v1.event.model.EventParams)1 Timed (io.micrometer.core.annotation.Timed)1 Binder (org.springframework.boot.context.properties.bind.Binder)1 InetUtils (org.springframework.cloud.commons.util.InetUtils)1 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)1 ConfigServerInstanceProvider (org.springframework.cloud.config.client.ConfigServerInstanceProvider)1 ConsulProperties (org.springframework.cloud.consul.ConsulProperties)1 ConsulDiscoveryClient (org.springframework.cloud.consul.discovery.ConsulDiscoveryClient)1 ConsulDiscoveryProperties (org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties)1 RefreshEvent (org.springframework.cloud.endpoint.event.RefreshEvent)1 Base64Utils.decodeFromString (org.springframework.util.Base64Utils.decodeFromString)1