/** * Returns list of services registered with the local agent. * @param resultHandler will be provided with list of services * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient localServices(Handler<AsyncResult<List<Service>>> resultHandler) { delegate.localServices(resultHandler); return this; }
/** * Returns list of services registered with the local agent. * @param resultHandler will be provided with list of services * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient localServices(Handler<AsyncResult<List<Service>>> resultHandler) { delegate.localServices(resultHandler); return this; }
@Override public ConsulService localServices(Handler<AsyncResult<List<Service>>> resultHandler) { consulClient.localServices(resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient localServices(io.vertx.ext.consul.ConsulClient j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.util.Map<String, Object>>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.localServices(resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<io.vertx.ext.consul.Service>>>() { public void handle(io.vertx.core.AsyncResult<java.util.List<io.vertx.ext.consul.Service>> ar) { resultHandler.handle(ar.map(event -> event != null ? event.stream().map(elt -> elt != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(elt.toJson()) : null).collect(java.util.stream.Collectors.toList()) : null)); } } : null)); return j_receiver; } public static io.vertx.ext.consul.ConsulClient localChecks(io.vertx.ext.consul.ConsulClient j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.util.Map<String, Object>>>> resultHandler) {
@Test public void bindCheckToService() { String serviceName = "serviceName"; ServiceOptions service = new ServiceOptions() .setName(serviceName) .setAddress("10.0.0.1") .setPort(8080); runAsync(h -> ctx.writeClient().registerService(service, h)); List<Service> services = getAsync(h -> ctx.writeClient().localServices(h)); Service s = services.stream().filter(i -> "serviceName".equals(i.getName())).findFirst().get(); String serviceId = s.getId(); assertEquals(s.getAddress(), "10.0.0.1"); assertEquals(s.getPort(), 8080); CheckOptions check = new CheckOptions() .setId("checkId") .setName("checkName") .setNotes("checkNotes") .setServiceId(serviceId) .setStatus(CheckStatus.PASSING) .setTtl("10s"); runAsync(h -> ctx.writeClient().registerCheck(check, h)); List<Check> checks = getAsync(h -> ctx.writeClient().localChecks(h)); Check c = checks.stream().filter(i -> "checkId".equals(i.getId())).findFirst().get(); assertEquals(c.getServiceId(), serviceId); assertEquals(c.getStatus(), CheckStatus.PASSING); assertEquals(c.getNotes(), "checkNotes"); runAsync(h -> ctx.writeClient().deregisterService(serviceId, h)); }
ServiceOptions opts = randomServiceOptions().setName(serviceName).setId(null); ctx.writeClient().registerService(opts, tc.asyncAssertSuccess(reg -> { ctx.writeClient().localServices(tc.asyncAssertSuccess(services -> { String serviceId = checkService(tc, services, serviceName, opts); ctx.writeClient().localChecks(tc.asyncAssertSuccess(checks -> { async.handler(v -> { ctx.writeClient().deregisterService(serviceId, tc.asyncAssertSuccess(deregistered -> { ctx.writeClient().localServices(tc.asyncAssertSuccess(cleaned -> { tc.assertEquals(cleaned.stream() .filter(i -> serviceName.equals(i.getName()))