Skip to content

Commit

Permalink
Add transaction accessor in Connection eclipse-vertx#646
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed May 20, 2020
1 parent 0a1a058 commit 1632699
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface SqlConnection extends SqlClient {
* Begin a transaction and returns a {@link Transaction} for controlling and tracking
* this transaction.
* <p/>
* When the connection is explicitely closed, any inflight transaction is rollbacked.
* When the connection is explicitely closed, any inflight transaction is rolled back.
*/
void begin(Handler<AsyncResult<Transaction>> handler);

Expand All @@ -77,6 +77,13 @@ public interface SqlConnection extends SqlClient {
*/
Future<Transaction> begin();

/**
* If @{link {@link #begin()} or {#link {@link #begin(Handler)} has been called, returns
* the associated transaction. Returns null otherwise.
* @return the current associated transaction, or null.
*/
Transaction currentTransaction();

/**
* @return whether the connection uses SSL
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void handleClosed() {
}
}

@Override
public Transaction currentTransaction() {
return tx;
}

@Override
public <R> void schedule(CommandBase<R> cmd, Promise<R> promise) {
if (tx != null) {
Expand Down

0 comments on commit 1632699

Please sign in to comment.