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

SQLConnection.x(...) for each PostgresClient.x(AsyncResult<SQLConnection> tx, ...)

    XMLWordPrintable

    Details

    • Type: Tech Debt
    • Status: Open (View Workflow)
    • Priority: P2
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Template:
    • Sprint:
      CP: Roadmap backlog
    • Development Team:
      Core: Platform

      Description

      PostgresClient's transactions currently require this effort:

      postgresClient.startTx(tx -> {
        postgresClient.getByIdAsStringForUpdate(tx, FOO, id, get -> {
          if (get.failed()) {
            // error handling
            return;
          }
          postgresClient.save(tx, FOO, xPojo, saved -> {
            if (saved.failed()) {
              // error handling
              return;
            }
            postgresClient.endTx(tx, endTx -> {
              if (endTx.failed()) {
                // error handling
                return;
              }
              // success handling
            });
          });
        });
      });
      

      Using futurisation reduces this to

      future = postgresClient.startTx().compose(conn -> {
        return conn.getByIdAsStringForUpdate(FOO, id)
        .compose(get -> conn.save(FOO, xPojo))
        .compose(save -> conn.endTx());
      });
      future. ...  // handle success and error
      

      RMB-741 "PostgresClient.withTransaction" will further reduce it to

      future = postgresClient.withTransaction(conn -> conn
        .getByIdAsStringForUpdate(FOO, id)
        .compose(get -> conn.save(FOO, xPojo)));
      future. ... // handle success and error
      

      Tasks

      • Create a SQLConnection.x(...) method for each PostgresClient.x(AsyncResult<SQLConnection> tx, ...) method.
      • Deprecate the PostgresClient.x method and link to the SQLConnection method.

      Examples:

      For PostgresClient's

      public void save(AsyncResult<SQLConnection> sqlConnection, String table, Object entity, Handler<AsyncResult<String>> replyHandler)
      

      create SQLConnection's

      public Future<String> save(String table, Object entity)
      

      For PostgresClient's

      public void rollbackTx(AsyncResult<SQLConnection> trans, Handler<AsyncResult<Void>> done)
      

      create SQLConnection's

      public Future<Void> rollbackTx()
      

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                julianladisch Julian Ladisch
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:

                    TestRail: Runs

                      TestRail: Cases