public static void toJson(ServiceQueryOptions obj, java.util.Map<String, Object> json) { if (obj.getBlockingOptions() != null) { json.put("blockingOptions", obj.getBlockingOptions().toJson()); } if (obj.getNear() != null) { json.put("near", obj.getNear()); } if (obj.getTag() != null) { json.put("tag", obj.getTag()); } } }
@Override public ConsulClient catalogServiceNodesWithOptions(String service, ServiceQueryOptions options, Handler<AsyncResult<ServiceList>> resultHandler) { Query query = options == null ? null : Query.of("tag", options.getTag()).put("near", options.getNear()).put(options.getBlockingOptions()); requestArray(HttpMethod.GET, "/v1/catalog/service/" + urlEncode(service), query, null, resultHandler, (arr, headers) -> { List<Service> list = arr.stream().map(obj -> new Service((JsonObject) obj)).collect(Collectors.toList()); return new ServiceList().setList(list).setIndex(Long.parseLong(headers.get(INDEX_HEADER))); }); return this; }
@Override public ConsulClient healthServiceNodesWithOptions(String service, boolean passing, ServiceQueryOptions options, Handler<AsyncResult<ServiceEntryList>> resultHandler) { Query query = new Query().put("passing", passing ? 1 : null); if (options != null) { query.put(options.getBlockingOptions()).put("near", options.getNear()).put("tag", options.getTag()); } requestArray(HttpMethod.GET, "/v1/health/service/" + urlEncode(service), query, null, resultHandler, (arr, headers) -> { List<ServiceEntry> list = arr.stream().map(obj -> ServiceEntryParser.parse((JsonObject) obj)).collect(Collectors.toList()); return new ServiceEntryList().setList(list).setIndex(Long.parseLong(headers.get(INDEX_HEADER))); }); return this; }