/** * Creates {@code Watch} to monitoring the custom user events. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/event.html#event_list">/v1/event/list</a> API internally. * * @param event the event name * @param vertx the {@code Vertx} instance * @return the {@code Watch} instance */ static Watch<EventList> events(String event, Vertx vertx) { return events(event, vertx, new ConsulClientOptions()); }
/** * Creates <code>Watch</code> to monitoring the custom user events. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/event.html#event_list">/v1/event/list</a> API internally. * @param event the event name * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<EventList> events(String event, io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<EventList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.events(event, vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
public static io.vertx.ext.consul.Watch<io.vertx.ext.consul.EventList> events(io.vertx.ext.consul.Watch<Object> j_receiver, java.lang.String event, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.consul.Watch.events(event, 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.NodeList> nodes(io.vertx.ext.consul.Watch<Object> j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) {
/** * Creates <code>Watch</code> to monitoring the custom user events. * This maps to the <a href="https://www.consul.io/docs/agent/http/event.html#event_list">/v1/event/list</a> API internally. * @param event the event name * @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<EventList> events(String event, io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<EventList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.events(event, vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the custom user events. * The underlying Consul client will be created with default options. * This maps to the <a href="https://www.consul.io/docs/agent/http/event.html#event_list">/v1/event/list</a> API internally. * @param event the event name * @param vertx the <code>Vertx</code> instance * @return the <code>Watch</code> instance */ public static io.vertx.rxjava.ext.consul.Watch<EventList> events(String event, io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.consul.Watch<EventList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.events(event, vertx.getDelegate()), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
/** * Creates <code>Watch</code> to monitoring the custom user events. * This maps to the <a href="https://www.consul.io/docs/agent/http/event.html#event_list">/v1/event/list</a> API internally. * @param event the event name * @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<EventList> events(String event, io.vertx.rxjava.core.Vertx vertx, ConsulClientOptions options) { io.vertx.rxjava.ext.consul.Watch<EventList> ret = io.vertx.rxjava.ext.consul.Watch.newInstance(io.vertx.ext.consul.Watch.events(event, vertx.getDelegate(), options), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
@Test public void watchEvents() throws InterruptedException { StateConsumer<String> consumer = new StateConsumer<>(); String evName = randomAlphaString(10); String p1 = randomAlphaString(10); String p2 = randomAlphaString(10); Watch<EventList> watch = Watch.events(evName, vertx, ctx.readClientOptions()) .setHandler(list -> { if (list.succeeded()) { consumer.consume(list.nextResult().getList() .stream().map(Event::getPayload).collect(Collectors.joining(","))); } }) .start(); consumer.await(""); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(evName, new EventOptions().setPayload(p1), h)); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(randomAlphaString(10), new EventOptions().setPayload(randomAlphaString(10)), h)); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(evName, new EventOptions().setPayload(p2), h)); consumer.await(p1); consumer.await(p1 + "," + p2); consumer.check(); watch.stop(); }