@Override public ConsulService getValueWithOptions(String key, BlockingQueryOptions options, Handler<AsyncResult<KeyValue>> resultHandler) { consulClient.getValueWithOptions(key, options, resultHandler); return this; }
/** * Returns key/value pair that corresponding to the specified key. * An empty {@link io.vertx.ext.consul.KeyValue} object will be returned if no such key is found. * This is blocking query unlike {@link io.vertx.rxjava.ext.consul.ConsulClient#getValue} * @param key the key * @param options the blocking options * @param resultHandler will be provided with key/value pair * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient getValueWithOptions(String key, BlockingQueryOptions options, Handler<AsyncResult<KeyValue>> resultHandler) { delegate.getValueWithOptions(key, options, resultHandler); return this; }
/** * Returns key/value pair that corresponding to the specified key. * An empty {@link io.vertx.ext.consul.KeyValue} object will be returned if no such key is found. * This is blocking query unlike {@link io.vertx.rxjava.ext.consul.ConsulClient#getValue} * @param key the key * @param options the blocking options * @param resultHandler will be provided with key/value pair * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient getValueWithOptions(String key, BlockingQueryOptions options, Handler<AsyncResult<KeyValue>> resultHandler) { delegate.getValueWithOptions(key, options, resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient getValueWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String key, 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.getValueWithOptions(key, 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.KeyValue>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.KeyValue> 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 getValues(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String keyPrefix, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
@Override void wait(long index, Handler<AsyncResult<State<KeyValue>>> handler) { BlockingQueryOptions options = new BlockingQueryOptions().setWait(BLOCKING_WAIT).setIndex(index); consulClient.getValueWithOptions(key, options, h -> handler.handle(h.map(kv -> new State<KeyValue>(kv, kv.getModifyIndex())))); } }
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())); }); })); } }