/** * Completion handler to receive a completion signal when this completions completes. * @param completionHandler the completion handler */ public void handler(Handler<AsyncResult<Void>> completionHandler) { delegate.handler(completionHandler); }
/** * Completion handler to receive a completion signal when this completions completes. * @param completionHandler the completion handler */ public void handler(Handler<AsyncResult<Void>> completionHandler) { delegate.handler(completionHandler); }
done.handler(r -> wrappedConsumer.close()); wrappedConsumer.handler(handler -> {
done.handler(r -> wrappedConsumer.close()); wrappedConsumer.handler(handler -> {
AtomicInteger count = new AtomicInteger(numMessages); Async batchHandler = ctx.async(); batchHandler.handler(ar -> wrappedConsumer.close()); wrappedConsumer.batchHandler(records -> { ctx.assertEquals(numMessages, records.size());
AtomicInteger count = new AtomicInteger(numMessages); Async batchHandler = ctx.async(); batchHandler.handler(ar -> wrappedConsumer.close()); wrappedConsumer.batchHandler(records -> { ctx.assertEquals(numMessages, records.size());
private void testSessionsBlocking(TestContext tc, BiConsumer<BlockingQueryOptions, Handler<AsyncResult<SessionList>>> request) { ctx.writeClient().createSession(tc.asyncAssertSuccess(id1 -> { ctx.readClient().listSessions(tc.asyncAssertSuccess(list1 -> { Async async = tc.async(); request.accept(new BlockingQueryOptions().setIndex(list1.getIndex()), h -> { List<String> ids = h.result().getList().stream().map(Session::getId).collect(Collectors.toList()); assertTrue(ids.contains(id1)); async.countDown(); }); vertx.setTimer(1000, l -> { assertEquals(async.count(), 1); ctx.writeClient().createSession(tc.asyncAssertSuccess(id2 -> { async.handler(a -> { ctx.writeClient().destroySession(id1, tc.asyncAssertSuccess(d1 -> { ctx.writeClient().destroySession(id2, tc.asyncAssertSuccess()); })); }); })); }); })); })); }
vertx.<ConsulAgent>executeBlocking(b1 -> b1.complete(ctx.attachAgent("attached_node")), tc.asyncAssertSuccess(attached -> { System.out.println(">>>>>>> new node attached"); async1.handler(v -> { ctx.readClient().catalogNodes(tc.asyncAssertSuccess(nodes2 -> { NodeQueryOptions blockingQueryOptions2 = new NodeQueryOptions()
async.countDown(); })); async.handler(v -> { ctx.writeClient().deregisterService(serviceId, tc.asyncAssertSuccess(deregistered -> { ctx.writeClient().localServices(tc.asyncAssertSuccess(cleaned -> {
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())); }); })); } }