Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-601

PgUtil futurisation for Vert.x 4

    XMLWordPrintable

Details

    • CP: sprint 107
    • 3
    • Core: Platform

    Description

      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

      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 PgUtil method that takes a Handler<AsyncResult<T>> parameter create a method without such parameter that returns a Future<T>.

      Background
      https://github.com/folio-org/raml-module-builder/blob/master/doc/futurisation.md
      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

      Implementation

      We will do a two step implementation – first we will add new APIs.
      We can then decide whether and when we remove the old code

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                mikhail.fokanov Mikhail Fokanov
                julianladisch Julian Ladisch
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases