Skip to content

Commit 54d1bdd

Browse files
Rename enum to TransactionPropagation
1 parent 50497ab commit 54d1bdd

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

vertx-sql-client/src/main/java/io/vertx/sqlclient/Pool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ default <T> void withTransaction(Function<SqlConnection, Future<@Nullable T>> fu
168168
* Like {@link #withTransaction(Function, Handler)} but allows for setting the mode, defining how the acquired
169169
* connection is managed during the execution of the function.
170170
*/
171-
<T> Future<@Nullable T> withTransaction(TransactionMode mode, Function<SqlConnection, Future<@Nullable T>> function);
171+
<T> Future<@Nullable T> withTransaction(TransactionPropagation txPropagation, Function<SqlConnection, Future<@Nullable T>> function);
172172

173173
/**
174174
* Get a connection from the pool and execute the given {@code function}.

vertx-sql-client/src/main/java/io/vertx/sqlclient/TransactionMode.java renamed to vertx-sql-client/src/main/java/io/vertx/sqlclient/TransactionPropagation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515

1616
/**
1717
* Defines how the acquired connection will be managed during the execution of the function provided in
18-
* {@link Pool#withTransaction(TransactionMode, Function)}.
18+
* {@link Pool#withTransaction(TransactionPropagation, Function)}.
1919
*/
20-
public enum TransactionMode {
20+
public enum TransactionPropagation {
2121

2222
/**
2323
* The acquired connection is not stored anywhere, making it local to the provided function execution and to
24-
* whereever it is passed.
24+
* wherever it is passed.
2525
*/
26-
DEFAULT,
26+
NONE,
2727

2828
/**
2929
* Keeps the acquired connection stored in the local context for as long as the given function executes.
3030
* Any subsequent calls to {@link Pool#withTransaction} with this mode during the function execution
3131
* will retrieve this connection from the context instead of creating another.
3232
* The connection is removed from the local context when the function block has completed.
3333
*/
34-
PROPAGATABLE
34+
CONTEXT
3535

3636
}

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/PoolBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public PreparedQuery<RowSet<Row>> preparedQuery(String sql) {
7272
}
7373

7474
@Override
75-
public <T> Future<@Nullable T> withTransaction(TransactionMode mode,
75+
public <T> Future<@Nullable T> withTransaction(TransactionPropagation txPropagation,
7676
Function<SqlConnection, Future<@Nullable T>> function) {
77-
return delegate.withTransaction(mode, function);
77+
return delegate.withTransaction(txPropagation, function);
7878
}
7979

8080
@Override

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/PoolImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ public Future<SqlConnection> getConnection() {
155155
});
156156
}
157157

158-
public <T> Future<@Nullable T> withTransaction(TransactionMode mode,
158+
public <T> Future<@Nullable T> withTransaction(TransactionPropagation txPropagation,
159159
Function<SqlConnection, Future<@Nullable T>> function) {
160-
if (mode == TransactionMode.PROPAGATABLE) {
160+
if (txPropagation == TransactionPropagation.CONTEXT) {
161161
ContextInternal context = (ContextInternal) Vertx.currentContext();
162162
SqlConnection sqlConnection = context.getLocal(PROPAGATABLE_CONNECTION);
163163
if (sqlConnection == null) {

vertx-sql-client/src/test/java/io/vertx/sqlclient/tck/TransactionTestBase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ public void testWithPropagatableConnectionTransactionCommit(TestContext ctx) {
314314
Async async = ctx.async();
315315
Pool pool = createPool();
316316
vertx.runOnContext(handler -> {
317-
pool.withTransaction(TransactionMode.PROPAGATABLE, c ->
318-
pool.withTransaction(TransactionMode.PROPAGATABLE, conn ->
317+
pool.withTransaction(TransactionPropagation.CONTEXT, c ->
318+
pool.withTransaction(TransactionPropagation.CONTEXT, conn ->
319319
conn.query("INSERT INTO mutable (id, val) VALUES (1, 'hello-1')").execute().mapEmpty()).flatMap(v ->
320-
pool.withTransaction(TransactionMode.PROPAGATABLE, conn ->
320+
pool.withTransaction(TransactionPropagation.CONTEXT, conn ->
321321
conn.query("INSERT INTO mutable (id, val) VALUES (2, 'hello-2')").execute().mapEmpty())).flatMap(v2 ->
322322
c.query("INSERT INTO mutable (id, val) VALUES (3, 'hello-3')").execute().mapEmpty())
323323
).onComplete(ctx.asyncAssertSuccess(v -> pool
@@ -336,8 +336,8 @@ public void testWithPropagatableConnectionTransactionRollback(TestContext ctx) {
336336
Pool pool = createPool();
337337
Throwable failure = new Throwable();
338338
vertx.runOnContext(handler -> {
339-
pool.withTransaction(TransactionMode.PROPAGATABLE, c ->
340-
pool.withTransaction(TransactionMode.PROPAGATABLE, conn ->
339+
pool.withTransaction(TransactionPropagation.CONTEXT, c ->
340+
pool.withTransaction(TransactionPropagation.CONTEXT, conn ->
341341
conn.query("INSERT INTO mutable (id, val) VALUES (1, 'hello-1')").execute().mapEmpty().flatMap(
342342
v -> Future.failedFuture(failure)))
343343
).onComplete(ctx.asyncAssertFailure(v -> pool

0 commit comments

Comments
 (0)