/** * Creates <code>Watch</code> to monitoring the list of available nodes. * This maps to the <a href="https://www.consul.io/api/catalog.html#list-nodes">/v1/catalog/nodes</a> API internally. * @param vertx the <code>Vertx</code> instance * @param options the options to create underlying Consul client * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<NodeList> nodes(io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<NodeList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.nodes(vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
public static io.vertx.ext.consul.Watch<io.vertx.ext.consul.NodeList> nodes(io.vertx.ext.consul.Watch<Object> j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.consul.Watch.nodes(vertx, options != null ? new io.vertx.ext.consul.ConsulClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } }
/** * Creates <code>Watch</code> to monitoring the list of available nodes. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/api/catalog.html#list-nodes">/v1/catalog/nodes</a> API internally. * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<NodeList> nodes(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<NodeList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.nodes(vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the list of available nodes. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/api/catalog.html#list-nodes">/v1/catalog/nodes</a> API internally. * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<NodeList> nodes(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<NodeList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.nodes(vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the list of available nodes. * This maps to the <a href="https://www.consul.io/api/catalog.html#list-nodes">/v1/catalog/nodes</a> API internally. * @param vertx the <code>Vertx</code> instance * @param options the options to create underlying Consul client * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<NodeList> nodes(io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<NodeList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.nodes(vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
@Test public void watchNodes() throws InterruptedException { StateConsumer<String> consumer = new StateConsumer<>(); String nodeName = randomAlphaString(10); Watch<NodeList> watch = Watch.nodes(vertx, ctx.readClientOptions()) .setHandler(list -> { if (list.succeeded()) { consumer.consume(list.nextResult().getList() .stream().map(Node::getName).filter(s -> s.equals(nodeName)) .findFirst().orElse("")); } }) .start(); consumer.await(""); ConsulAgent attached = ctx.attachAgent(nodeName); ctx.detachAgent(attached); consumer.await(nodeName); consumer.await(""); consumer.check(); watch.stop(); } }