@Override public ConsulService getValuesWithOptions(String keyPrefix, BlockingQueryOptions options, Handler<AsyncResult<KeyValueList>> resultHandler) { consulClient.getValuesWithOptions(keyPrefix, options, resultHandler); return this; }
/** * Returns the list of key/value pairs that corresponding to the specified key prefix. * An empty {@link io.vertx.ext.consul.KeyValueList} object will be returned if no such key prefix is found. * This is blocking query unlike {@link io.vertx.rxjava.ext.consul.ConsulClient#getValues} * @param keyPrefix the prefix * @param options the blocking options * @param resultHandler will be provided with list of key/value pairs * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient getValuesWithOptions(String keyPrefix, BlockingQueryOptions options, Handler<AsyncResult<KeyValueList>> resultHandler) { delegate.getValuesWithOptions(keyPrefix, options, resultHandler); return this; }
/** * Returns the list of key/value pairs that corresponding to the specified key prefix. * An empty {@link io.vertx.ext.consul.KeyValueList} object will be returned if no such key prefix is found. * This is blocking query unlike {@link io.vertx.rxjava.ext.consul.ConsulClient#getValues} * @param keyPrefix the prefix * @param options the blocking options * @param resultHandler will be provided with list of key/value pairs * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient getValuesWithOptions(String keyPrefix, BlockingQueryOptions options, Handler<AsyncResult<KeyValueList>> resultHandler) { delegate.getValuesWithOptions(keyPrefix, options, resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient getValuesWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String keyPrefix, 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.getValuesWithOptions(keyPrefix, options != null ? new io.vertx.ext.consul.BlockingQueryOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.consul.KeyValueList>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.KeyValueList> 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 putValueWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String key, java.lang.String value, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>> resultHandler) {
@Override void wait(long index, Handler<AsyncResult<State<KeyValueList>>> handler) { BlockingQueryOptions options = new BlockingQueryOptions().setWait(BLOCKING_WAIT).setIndex(index); consulClient.getValuesWithOptions(keyPrefix, options, h -> handler.handle(h.map(kv -> new State<KeyValueList>(kv, kv.getIndex())))); } }
private void blockingQuery(TestContext tc, BiConsumer<String, Handler<Long>> indexSupplier) { String key = randomFooBarAlpha(); String value = randomAlphaString(10); ctx.writeClient() .putValue(key, randomAlphaString(10), tc.asyncAssertSuccess(b1 -> { tc.assertTrue(b1); indexSupplier.accept(key, consulIndex -> { Async async = tc.async(2); vertx.setTimer(TimeUnit.SECONDS.toMillis(2), l -> { ctx.writeClient().putValue(key, value, tc.asyncAssertSuccess(b2 -> { tc.assertTrue(b2); ctx.readClient().getValueWithOptions(key, new BlockingQueryOptions().setIndex(consulIndex), tc.asyncAssertSuccess(kv -> { tc.assertTrue(kv.getModifyIndex() > consulIndex); tc.assertEquals(kv.getValue(), value); async.countDown(); })); ctx.readClient().getValuesWithOptions("foo/bar", new BlockingQueryOptions().setIndex(consulIndex), tc.asyncAssertSuccess(kv -> { tc.assertTrue(kv.getIndex() > consulIndex); tc.assertTrue(kv.getList().size() == 1); async.countDown(); })); })); }); async.handler(v -> ctx.writeClient().deleteValue(key, tc.asyncAssertSuccess())); }); })); } }