Details
-
Tech Debt
-
Status: Open (View Workflow)
-
P2
-
Resolution: Unresolved
-
None
-
None
-
-
CP: Roadmap backlog
-
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
- relates to
-
RMB-388 PostgresClient.getById with transaction, with "SELECT … FOR UPDATE"
-
- Closed
-
-
RMB-601 PgUtil futurisation for Vert.x 4
-
- Closed
-
-
RMB-602 PostgresClient futurisation for Vert.x 4, Part 1
-
- Closed
-
-
RMB-741 PostgresClient.withTransaction
-
- Closed
-
-
RMB-814 PostgresClient futurisation for Vert.x 4, Part 2
-
- Closed
-