@Override public ConsulService catalogServiceNodesWithOptions(String service, ServiceQueryOptions options, Handler<AsyncResult<ServiceList>> resultHandler) { consulClient.catalogServiceNodesWithOptions(service, options, resultHandler); return this; }
/** * Returns the nodes providing a service * @param service name of service * @param options options used to request services * @param resultHandler will be provided with list of nodes providing given service * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient catalogServiceNodesWithOptions(String service, ServiceQueryOptions options, Handler<AsyncResult<ServiceList>> resultHandler) { delegate.catalogServiceNodesWithOptions(service, options, resultHandler); return this; }
/** * Returns the nodes providing a service * @param service name of service * @param options options used to request services * @param resultHandler will be provided with list of nodes providing given service * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient catalogServiceNodesWithOptions(String service, ServiceQueryOptions options, Handler<AsyncResult<ServiceList>> resultHandler) { delegate.catalogServiceNodesWithOptions(service, options, resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient catalogServiceNodesWithOptions(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) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.catalogServiceNodesWithOptions(service, options != null ? new io.vertx.ext.consul.ServiceQueryOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null, 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 catalogNodes(io.vertx.ext.consul.ConsulClient j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
@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); }
Async async = tc.async(2); ServiceQueryOptions knownOpts = new ServiceQueryOptions().setTag(opts.getTags().get(0)); ctx.writeClient().catalogServiceNodesWithOptions(serviceName, knownOpts, tc.asyncAssertSuccess(nodeServicesWithKnownTag -> { tc.assertEquals(1, nodeServicesWithKnownTag.getList().size()); async.countDown(); })); ServiceQueryOptions unknownOpts = new ServiceQueryOptions().setTag("unknownTag"); ctx.writeClient().catalogServiceNodesWithOptions(serviceName, unknownOpts, tc.asyncAssertSuccess(nodeServicesWithUnknownTag -> { tc.assertEquals(0, nodeServicesWithUnknownTag.getList().size()); async.countDown();