本文整理了Java中io.vertx.core.Future.handle()
方法的一些代码示例,展示了Future.handle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.handle()
方法的具体详情如下:
包路径:io.vertx.core.Future
类名称:Future
方法名:handle
暂无
代码示例来源:origin: vert-x3/vertx-web
@Override
public void handle(AsyncResult<Boolean> asyncResult) {
future.handle(asyncResult);
}
代码示例来源:origin: io.vertx/vertx-web
@Override
public void handle(AsyncResult<Boolean> asyncResult) {
future.handle(asyncResult);
}
代码示例来源:origin: io.vertx/vertx-tcp-eventbus-bridge
@Override
public void handle(AsyncResult<Boolean> asyncResult) {
future.handle(asyncResult);
}
代码示例来源:origin: vert-x3/vertx-tcp-eventbus-bridge
@Override
public void handle(AsyncResult<Boolean> asyncResult) {
future.handle(asyncResult);
}
代码示例来源:origin: reactiverse/reactive-pg-client
public void close() {
if (closed) {
throw new IllegalStateException("Connection pool already closed");
}
closed = true;
for (PooledConnection pooled : new ArrayList<>(all)) {
pooled.close();
}
Future<Connection> failure = Future.failedFuture("Connection pool close");
for (Future<Connection> pending : waiters) {
try {
pending.handle(failure);
} catch (Exception ignore) {
}
}
}
代码示例来源:origin: io.reactiverse/reactive-pg-client
public void close() {
if (closed) {
throw new IllegalStateException("Connection pool already closed");
}
closed = true;
for (PooledConnection pooled : new ArrayList<>(all)) {
pooled.close();
}
Future<Connection> failure = Future.failedFuture("Connection pool close");
for (Future<Connection> pending : waiters) {
try {
pending.handle(failure);
} catch (Exception ignore) {
}
}
}
代码示例来源:origin: cescoffier/vertx-microservices-workshop
private Future<Void> retrieveAuditService() {
return Future.future(future -> {
HttpEndpoint.getWebClient(discovery, new JsonObject().put("name", "audit"), client -> {
this.client = client.result();
future.handle(client.map((Void)null));
});
});
}
代码示例来源:origin: strimzi/strimzi-kafka-operator
/**
* Start an HTTP health server
*/
private Future<HttpServer> startHealthServer() {
Future<HttpServer> result = Future.future();
this.vertx.createHttpServer()
.requestHandler(request -> {
if (request.path().equals("/healthy")) {
request.response().setStatusCode(200).end();
} else if (request.path().equals("/ready")) {
request.response().setStatusCode(200).end();
}
})
.listen(HEALTH_SERVER_PORT, ar -> {
if (ar.succeeded()) {
log.info("ClusterOperator is now ready (health server listening on {})", HEALTH_SERVER_PORT);
} else {
log.error("Unable to bind health server on {}", HEALTH_SERVER_PORT, ar.cause());
}
result.handle(ar);
});
return result;
}
代码示例来源:origin: strimzi/strimzi-kafka-operator
/**
* Start an HTTP health server
*/
private Future<HttpServer> startHealthServer() {
Future<HttpServer> result = Future.future();
this.vertx.createHttpServer()
.requestHandler(request -> {
if (request.path().equals("/healthy")) {
request.response().setStatusCode(200).end();
} else if (request.path().equals("/ready")) {
request.response().setStatusCode(200).end();
}
})
.listen(HEALTH_SERVER_PORT, ar -> {
if (ar.succeeded()) {
log.info("UserOperator is now ready (health server listening on {})", HEALTH_SERVER_PORT);
} else {
log.error("Unable to bind health server on {}", HEALTH_SERVER_PORT, ar.cause());
}
result.handle(ar);
});
return result;
}
代码示例来源:origin: cescoffier/vertx-kubernetes-workshop
@Override
public void start(Future<Void> future) throws Exception {
Router router = Router.router(vertx);
router.get().handler(rc -> rc.response().end("OK"));
router.post().handler(BodyHandler.create());
router.post().handler(this::handle);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(config().getInteger("port", 8080),
ar -> future.handle(ar.mapEmpty()));
}
代码示例来源:origin: folio-org/okapi
private void healthList(List<DeploymentDescriptor> list,
Handler<ExtendedAsyncResult<List<HealthDescriptor>>> fut) {
List<HealthDescriptor> all = new LinkedList<>();
CompList<List<HealthDescriptor>> futures = new CompList<>(INTERNAL);
for (DeploymentDescriptor md : list) {
Future<HealthDescriptor> f = Future.future();
health(md, res -> {
if (res.succeeded()) {
all.add(res.result());
}
f.handle(res);
});
futures.add(f);
}
futures.all(all, fut);
}
代码示例来源:origin: folio-org/okapi
/**
* Get all modules that are enabled for the given tenant.
*
* @param ten tenant to check for
* @param fut callback with a list of ModuleDescriptors (may be empty list)
*/
public void getEnabledModules(Tenant ten,
Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
List<ModuleDescriptor> mdl = new LinkedList<>();
CompList<List<ModuleDescriptor>> futures = new CompList<>(INTERNAL);
for (String id : ten.getEnabled().keySet()) {
Future<ModuleDescriptor> f = Future.future();
modules.get(id, res -> {
if (res.succeeded()) {
mdl.add(res.result());
}
f.handle(res);
});
futures.add(f);
}
futures.all(mdl, fut);
}
}
代码示例来源:origin: vietj/vertx-http-proxy
@Override
public void start(Future<Void> startFuture) {
HttpClient proxyClient = vertx.createHttpClient(new HttpClientOptions(clientOptions));
HttpServer proxyServer = vertx.createHttpServer(new HttpServerOptions(proxyOptions));
HttpProxy proxy = HttpProxy.reverseProxy(proxyClient);
proxy.selector(selector);
proxyServer.requestHandler(proxy);
proxyServer.listen(ar -> startFuture.handle(ar.mapEmpty()));
}
}, ar -> {
代码示例来源:origin: folio-org/okapi
public void getNodes(Handler<ExtendedAsyncResult<List<NodeDescriptor>>> fut) {
nodes.getKeys(resGet -> {
if (resGet.failed()) {
fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
} else {
Collection<String> keys = resGet.result();
if (clusterManager != null) {
List<String> n = clusterManager.getNodes();
keys.retainAll(n);
}
List<NodeDescriptor> all = new LinkedList<>();
CompList<List<NodeDescriptor>> futures = new CompList<>(INTERNAL);
for (String nodeId : keys) {
Future<NodeDescriptor> f = Future.future();
getNode1(nodeId, res -> {
if (res.succeeded()) {
all.add(res.result());
}
f.handle(res);
});
futures.add(f);
}
futures.all(all, fut);
}
});
}
代码示例来源:origin: vert-x3/vertx-kafka-client
@Override
public void start(Future<Void> startFuture) throws Exception {
Properties config = new Properties();
config.putAll(context.config().getMap());
KafkaProducer<String, String> producer = KafkaProducer.createShared(vertx, "the-name", config);
producer.write(KafkaProducerRecord.create("the_topic", "the_value"), ar -> startFuture.handle(ar.map((Void) null)));
}
}
代码示例来源:origin: io.vertx/vertx-kafka-client
@Override
public void start(Future<Void> startFuture) throws Exception {
Properties config = new Properties();
config.putAll(context.config().getMap());
KafkaProducer<String, String> producer = KafkaProducer.createShared(vertx, "the-name", config);
producer.write(KafkaProducerRecord.create("the_topic", "the_value"), ar -> startFuture.handle(ar.map((Void) null)));
}
}
代码示例来源:origin: folio-org/okapi
public void list(Handler<ExtendedAsyncResult<List<TenantDescriptor>>> fut) {
tenants.getKeys(lres -> {
if (lres.failed()) {
logger.warn("TenantManager list: Getting keys FAILED: ", lres);
fut.handle(new Failure<>(INTERNAL, lres.cause()));
} else {
CompList<List<TenantDescriptor>> futures = new CompList<>(INTERNAL);
List<TenantDescriptor> tdl = new LinkedList<>();
for (String s : lres.result()) {
Future<Tenant> future = Future.future();
tenants.get(s, res -> {
if (res.succeeded()) {
tdl.add(res.result().getDescriptor());
}
future.handle(res);
});
futures.add(future);
}
futures.all(tdl, fut);
}
});
}
代码示例来源:origin: folio-org/okapi
private void removeAndUndeploy(ProxyContext pc,
List<DeploymentDescriptor> ddList, Handler<ExtendedAsyncResult<Void>> fut) {
CompList<List<Void>> futures = new CompList<>(INTERNAL);
for (DeploymentDescriptor dd : ddList) {
Future<Void> f = Future.future();
logger.info("removeAndUndeploy " + dd.getSrvcId() + " " + dd.getInstId());
callUndeploy(dd, pc, res -> {
if (res.succeeded()) {
deploymentStore.delete(dd.getInstId(), f::handle);
} else {
f.handle(res);
}
});
futures.add(f);
}
futures.all(fut);
}
代码示例来源:origin: io.vertx/vertx-config
@Override
public void start(Future<Void> future) {
message = config().getString("message");
String address = config().getString("address");
Future<Void> endpointReady = Future.future();
Future<Void> updateReady = Future.future();
vertx.eventBus().<JsonObject>consumer(address + "/update")
.handler(json -> {
message = json.body().getString("message");
json.reply("OK");
})
.completionHandler(updateReady);
vertx.eventBus().consumer(address)
.handler(msg -> msg.reply(message))
.completionHandler(endpointReady);
CompositeFuture.all(endpointReady, updateReady).setHandler(x -> future.handle(x.mapEmpty()));
}
}
代码示例来源:origin: vert-x3/vertx-config
@Override
public void start(Future<Void> future) {
message = config().getString("message");
String address = config().getString("address");
Future<Void> endpointReady = Future.future();
Future<Void> updateReady = Future.future();
vertx.eventBus().<JsonObject>consumer(address + "/update")
.handler(json -> {
message = json.body().getString("message");
json.reply("OK");
})
.completionHandler(updateReady);
vertx.eventBus().consumer(address)
.handler(msg -> msg.reply(message))
.completionHandler(endpointReady);
CompositeFuture.all(endpointReady, updateReady).setHandler(x -> future.handle(x.mapEmpty()));
}
}
内容来源于网络,如有侵权,请联系作者删除!