/** * Returns the checks associated with the service * @param service the service name * @param resultHandler will be provided with list of checks * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient healthChecks(String service, Handler<AsyncResult<CheckList>> resultHandler) { delegate.healthChecks(service, resultHandler); return this; }
.setName("checkName1"), h)); CheckList list1 = getAsync(h -> ctx.readClient().healthChecks("serviceName", h)); assertEquals(list1.getList().size(), 1); assertEquals(list1.getList().get(0).getId(), "checkId1");
/** * Returns the checks associated with the service * @param service the service name * @param resultHandler will be provided with list of checks * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient healthChecks(String service, Handler<AsyncResult<CheckList>> resultHandler) { delegate.healthChecks(service, resultHandler); return this; }
@Override public ConsulService healthChecks(String service, Handler<AsyncResult<CheckList>> resultHandler) { consulClient.healthChecks(service, resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient healthChecks(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String service, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.healthChecks(service, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.consul.CheckList>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.CheckList> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null)); return j_receiver; } public static io.vertx.ext.consul.ConsulClient healthChecksWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String service, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
private Future serviceToRecord(Service service) { //use the checks to set the record status Future<CheckList> checkListFuture = Future.future(); client.healthChecks(service.getName(), checkListFuture); return checkListFuture.map(cl -> cl.getList().stream().map(Check::getStatus).allMatch(CheckStatus.PASSING::equals)) .map(st -> st ? new Record().setStatus(Status.UP) : new Record().setStatus(Status.DOWN)) .map(record -> { record.setMetadata(new JsonObject()); record.setLocation(new JsonObject()); record.setName(service.getName()); record.setRegistration(service.getId()); List<String> tags = service.getTags(); record.setType(ServiceType.UNKNOWN); ServiceTypes.all().forEachRemaining(type -> { if (service.getTags().contains(type.name())) { record.setType(type.name()); tags.remove(type.name()); } }); //retrieve the metadata object tags.stream().filter(t -> t.startsWith("metadata:")).map(s -> s.substring("metadata:".length())).map(JsonObject::new).forEach(json -> record.getMetadata().mergeIn(json)); //retrieve the location object tags.stream().filter(t -> t.startsWith("location:")).map(s -> s.substring("location:".length())).map(JsonObject::new).forEach(json -> record.getLocation().mergeIn(json)); record.getMetadata().put("tags", new JsonArray(tags.stream().filter(t -> !t.startsWith("metadata:") && !t.startsWith("location:")).collect(Collectors.toList()))); return record; }); } }