use of io.vertx.core.Future in project vertx-examples by vert-x3.
the class HttpVerticle method start.
@Override
public void start(Future<Void> startFuture) throws Exception {
HttpServerOptions options = new HttpServerOptions().setPort(config().getInteger("port"));
vertx.createHttpServer(options).requestHandler(request -> {
String name = request.getParam("name");
if (name == null) {
request.response().setStatusCode(400).end("Missing name");
} else {
vertx.eventBus().<String>send("hello", name, ar -> {
if (ar.succeeded()) {
request.response().end(ar.result().body());
} else {
request.response().setStatusCode(500).end(ar.cause().getMessage());
}
});
}
}).listen(ar -> {
if (ar.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(ar.cause());
}
});
}
use of io.vertx.core.Future in project incubator-servicecomb-java-chassis by apache.
the class MockForRestServerVerticle method mockRestServerVerticle.
public void mockRestServerVerticle() {
final HttpServer server = Mockito.mock(HttpServer.class);
new MockUp<RestServerVerticle>() {
@Mock
private void startListen(HttpServer server, IpPort ipPort, Future<Void> startFuture) {
}
@Mock
private HttpServer createHttpServer(boolean isHttp_2) {
return server;
}
};
}
use of io.vertx.core.Future in project raml-module-builder by folio-org.
the class PostgresClient method get.
public void get(Object conn, String table, Class<?> clazz, Criterion filter, boolean returnCount, boolean setId, List<FacetField> facets, Handler<AsyncResult<Results>> replyHandler) {
StringBuilder sb = new StringBuilder();
StringBuilder fromClauseFromCriteria = new StringBuilder();
if (filter != null) {
sb.append(filter.toString());
fromClauseFromCriteria.append(filter.from2String());
if (fromClauseFromCriteria.length() > 0) {
fromClauseFromCriteria.insert(0, ",");
}
}
if (conn == null) {
get(table, clazz, DEFAULT_JSONB_FIELD_NAME, fromClauseFromCriteria.toString() + sb.toString(), returnCount, true, setId, facets, replyHandler);
} else {
SQLConnection sqlConnection = ((Future<SQLConnection>) conn).result();
doGet(sqlConnection, true, table, clazz, DEFAULT_JSONB_FIELD_NAME, fromClauseFromCriteria.toString() + sb.toString(), returnCount, true, setId, facets, replyHandler);
}
}
use of io.vertx.core.Future in project raml-module-builder by folio-org.
the class PostgresClient method delete.
public void delete(Object conn, String table, Criterion filter, Handler<AsyncResult<UpdateResult>> replyHandler) {
SQLConnection sqlConnection = ((Future<SQLConnection>) conn).result();
StringBuilder sb = new StringBuilder();
if (filter != null) {
sb.append(filter.toString());
}
doDelete(sqlConnection, true, table, sb.toString(), replyHandler);
}
use of io.vertx.core.Future in project raml-module-builder by folio-org.
the class PostgresClient method rollbackTx.
// @Timer
@SuppressWarnings("unchecked")
public void rollbackTx(Object conn, Handler<AsyncResult<Object>> done) {
SQLConnection sqlConnection = ((Future<SQLConnection>) conn).result();
sqlConnection.rollback(res -> {
sqlConnection.close();
if (res.failed()) {
log.error(res.cause().getMessage(), res.cause());
done.handle(Future.failedFuture(res.cause()));
} else {
done.handle(Future.succeededFuture(res));
}
});
}
Aggregations