Done
Details
Assignee
Julian LadischJulian LadischReporter
Julian LadischJulian LadischLabels
Priority
P3Story Points
8Sprint
NoneDevelopment Team
Core: PlatformFix versions
TestRail: Cases
Open TestRail: CasesTestRail: Runs
Open TestRail: Runs
Details
Details
Assignee
Julian Ladisch
Julian LadischReporter
Julian Ladisch
Julian LadischLabels
Priority
Story Points
8
Sprint
None
Development Team
Core: Platform
Fix versions
TestRail: Cases
Open TestRail: Cases
TestRail: Runs
Open TestRail: Runs
Created April 21, 2020 at 9:22 AM
Updated April 21, 2021 at 10:11 AM
Resolved March 15, 2021 at 12:52 PM
This is part 1. Part 2 is RMB-814.
Example:
public interface NetClient { // Since 3.0 void connect(int port, String host, Handler<AsyncResult<NetSocket>> handler); // New in 4.0 Future<NetSocket> connect(int port, String host); }
This hybrid model has already been implemented in
Vert.x Core library: https://vertx.io/blog/eclipse-vert-x-4-milestone-1-released/#core-futurisation
vertx-auth, vertx-web, vertx-mqtt, vertx-cassandra-client, vertx-redis-client, vertx-kakfa-client, vertx-amqp-client https://vertx.io/blog/eclipse-vert-x-4-milestone-2-released/#futurisation
vertx-service-discovery, vertx-config, vertx-circuit-breaker https://vertx.io/blog/eclipse-vert-x-4-milestone-3-released/#futurisation
Vert.x Shell, Vert.x Mail Client, Vert.x Consul Client, Vert.x RabbitMQ Client, Vert.x Stomp, Vert.x Mongo Client https://vertx.io/blog/eclipse-vert-x-4-milestone-4-released/#futurisation
The methods that return a future allow the more easy to use and more intuitive way for async coordination, example code from vertx-core doc:
Future<HttpServer> httpServerFuture = Future.future(promise -> httpServer.listen(promise)); Future<NetServer> netServerFuture = Future.future(promise -> netServer.listen(promise)); CompositeFuture.all(httpServerFuture, netServerFuture).onComplete(ar -> { if (ar.succeeded()) { // All servers started } else { // At least one server failed } });
Task:
For each PostgresClient method that takes a Handler<AsyncResult<T>> parameter create a function without such parameter that returns a Future<T>.
This can easily been split into several sub-tasks because there are many independent methods. This allows for smaller pull requests and early code review feedback.
For details see
https://github.com/folio-org/raml-module-builder/blob/master/doc/futurisation.md
Implementation notes:
RMB-741 "PostgresClient.withTransaction" should be complete before we start with this.
RMB-758 "SQLConnection.x(...) for each PostgresClient.x(AsyncResult<SQLConnection> tx, ...)" is a sub-task of this issue and should be worked on at the same time.
The existing method should call the new method and do
.onComplete(promise)
to avoid creating yet another promise, for details see https://github.com/folio-org/raml-module-builder/blob/master/doc/futurisation.md#future-as-return-value