/** * Creates {@code Watch} to monitoring the list of available services. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/catalog.html#catalog_services">/v1/catalog/services</a> API internally. * * @param vertx the {@code Vertx} instance * @return the {@code Watch} instance */ static Watch<ServiceList> services(Vertx vertx) { return services(vertx, new ConsulClientOptions()); }
/** * Creates <code>Watch</code> to monitoring the list of available services. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/catalog.html#catalog_services">/v1/catalog/services</a> API internally. * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<ServiceList> services(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<ServiceList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.services(vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
public static io.vertx.ext.consul.Watch<io.vertx.ext.consul.ServiceList> services(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.services(vertx, options != null ? new io.vertx.ext.consul.ConsulClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.consul.Watch<io.vertx.ext.consul.ServiceEntryList> service(io.vertx.ext.consul.Watch<Object> j_receiver, java.lang.String service, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) {
/** * Creates <code>Watch</code> to monitoring the list of available services. * This maps to the <a href="https://www.consul.io/docs/agent/http/catalog.html#catalog_services">/v1/catalog/services</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<ServiceList> services(io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<ServiceList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.services(vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the list of available services. * This maps to the <a href="https://www.consul.io/docs/agent/http/catalog.html#catalog_services">/v1/catalog/services</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<ServiceList> services(io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<ServiceList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.services(vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the list of available services. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/catalog.html#catalog_services">/v1/catalog/services</a> API internally. * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<ServiceList> services(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<ServiceList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.services(vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
@Test public void watchServices() throws InterruptedException { StateConsumer<String> consumer = new StateConsumer<>(); ServiceOptions service = new ServiceOptions() .setId(randomAlphaString(10)) .setName(randomAlphaString(10)); Watch<ServiceList> watch = Watch.services(vertx, ctx.readClientOptions()) .setHandler(list -> { if (list.succeeded()) { consumer.consume(list.nextResult().getList() .stream().map(Service::getName).filter(s -> s.equals(service.getName())) .findFirst().orElse("")); } }) .start(); consumer.await(""); runAsync(h -> ctx.writeClient().registerService(service, h)); consumer.await(service.getName()); consumer.check(); watch.stop(); runAsync(h -> ctx.writeClient().deregisterService(service.getId(), h)); }