/** * Returns the services registered in a datacenter * @param resultHandler will be provided with list of services * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient catalogServices(Handler<AsyncResult<ServiceList>> resultHandler) { delegate.catalogServices(resultHandler); return this; }
@Test public void catalogServicesBlocking() throws InterruptedException { testServicesBlocking(h -> ctx.readClient().catalogServices(h), (opts, h) -> ctx.readClient().catalogServicesWithOptions(opts, h)); }
@Override public ConsulService catalogServices(Handler<AsyncResult<ServiceList>> resultHandler) { consulClient.catalogServices(resultHandler); return this; }
/** * Returns the services registered in a datacenter * @param resultHandler will be provided with list of services * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient catalogServices(Handler<AsyncResult<ServiceList>> resultHandler) { delegate.catalogServices(resultHandler); return this; }
private void retrieveServicesFromConsul(Future<List<ImportedConsulService>> completed) { client.catalogServices(ar -> { if (ar.succeeded()) { retrieveIndividualServices(ar.result(), completed); } else { completed.fail(ar.cause()); } }); }
public static io.vertx.ext.consul.ConsulClient catalogServices(io.vertx.ext.consul.ConsulClient j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.catalogServices(resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.consul.ServiceList>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.ServiceList> 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 catalogServicesWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
private void retrieveServicesFromConsul(Future<List<ImportedConsulService>> completed) { client.catalogServices(ar -> { if (ar.succeeded()) { retrieveIndividualServices(ar.result(), completed); } else { completed.fail(ar.cause()); } }); }
@Override public void getRecords(Handler<AsyncResult<List<Record>>> resultHandler) { Future<ServiceList> nameList = Future.future(); client.catalogServices(nameList); nameList.map(ServiceList::getList) .map(l -> { List<Future> recordFutureList = new ArrayList<>(); l.forEach(s -> { if (!"consul".equals(s.getName())) { ServiceQueryOptions opt = new ServiceQueryOptions(); if (!s.getTags().isEmpty()) { opt.setTag(s.getTags().get(0)); } Future<ServiceList> serviceList = Future.future(); client.catalogServiceNodesWithOptions(s.getName(), opt, serviceList); recordFutureList.add(serviceList); } }); return recordFutureList; }) .compose(CompositeFuture::all) .map(c -> c.<ServiceList>list().stream().flatMap(l -> l.getList().stream()).map(this::serviceToRecord).collect(Collectors.toList())) .compose(CompositeFuture::all) .map(c -> c.list().stream().map(o -> (Record) o).collect(Collectors.toList())) .setHandler(resultHandler); }
@Test public void findConsul() { ServiceList localConsulList = getAsync(h -> ctx.writeClient().catalogServiceNodes("consul", h)); assertEquals(localConsulList.getList().size(), 1); List<Service> catalogConsulList = Utils.<ServiceList>getAsync(h -> ctx.writeClient().catalogServices(h)) .getList().stream().filter(s -> s.getName().equals("consul")).collect(Collectors.toList()); assertEquals(1, catalogConsulList.size()); assertEquals(0, catalogConsulList.get(0).getTags().size()); }