public static ConsulResponse<Value> awaitChange(KeyValueClient kv, String key, BigInteger index) { while (true) { final ConsulResponse<Value> response = kv.getConsulResponseWithValue(key, ImmutableQueryOptions.builder() .index(index) .wait("5m") .build()) .orElse(null); if (response == null) { LOGGER.debug("Document does not exist: {}", key); return null; } if (index.equals(response.getIndex())) { LOGGER.debug("Long poll timed out, polling again for {}", key); } else { return response; } } }
ImmutableQueryOptions.builder() .index(index) .wait(waitSeconds + "s") .build()) .orElse(null);
private static ImmutableQueryOptions.Builder blockBuilder(String identifier, int qty, BigInteger index) { return ImmutableQueryOptions.builder() .wait(String.format("%s%s", qty, identifier)) .index(index); }
Optional<String> waitOptional = instance.getWait(); if (waitOptional.isPresent()) { wait(waitOptional);
@Override public void run() { CatalogClient client = this.catalogClientInjector.getValue(); BigInteger index = null; while (true) { QueryOptions options = QueryOptions.BLANK; if (index != null) { options = ImmutableQueryOptions.builder() .wait("60s") .index(index) .build(); } ConsulResponse<Map<String, List<String>>> services = client.getServices(options); index = services.getIndex(); Map<String, List<String>> response = services.getResponse(); response.keySet().forEach(e -> { setupWatcher(e); }); try { Thread.sleep(1000); } catch (InterruptedException e) { break; } } }
public static void awaitRemoval(KeyValueClient kv, String key) { BigInteger index = BigInteger.ZERO; while (true) { final ConsulResponse<Value> response = kv.getConsulResponseWithValue(key, ImmutableQueryOptions.builder() .index(index) .wait("5m") .build()) .orElse(null); if (response == null) { return; } index = response.getIndex(); } }