8000 Interfaces decomposition fixed. Now a transaction can only be started… · LarsG/postgres-async-driver@b537fae · GitHub
[go: up one dir, main page]

Skip to content

Commit b537fae

Browse files
Interfaces decomposition fixed. Now a transaction can only be started from a connection or another transaction
1 parent f956971 commit b537fae

File tree

6 files changed

+194
-176
lines changed

6 files changed

+194
-176
lines changed

src/main/java/com/github/pgasync/PgConnectible.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import com.github.pgasync.conversion.DataConverter;
44
import com.pgasync.ConnectibleBuilder;
5-
import com.pgasync.Connection;
65
import com.pgasync.Connectible;
76
import com.pgasync.Row;
8-
import com.pgasync.Transaction;
97

108
import java.nio.charset.Charset;
119
import java.util.Map;
@@ -39,13 +37,6 @@ public abstract class PgConnectible implements Connectible {
3937
this.futuresExecutor = futuresExecutor;
4038
}
4139

42-
@Override
43-
public CompletableFuture<Transaction> begin() {
44-
return getConnection()
45-
.thenApply(Connection::begin)
46-
.thenCompose(Function.identity());
47-
}
48-
4940
@Override
5041
public CompletableFuture<Void> script(BiConsumer<Map<String, PgColumn>, PgColumn[]> onColumns, Consumer<Row> onRow, Consumer<Integer> onAffected, String sql) {
5142
return getConnection()

src/main/java/com/github/pgasync/PgConnectionPool.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,5 +404,4 @@ private CompletableFuture<Void> release(PooledPgConnection connection) {
404404
}
405405
return CompletableFuture.completedFuture(null);
406406
}
407-
408407
}

src/main/java/com/pgasync/Connection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.concurrent.CompletableFuture;
2020
import java.util.function.Consumer;
21+
import java.util.function.Function;
2122

2223
/**
2324
* A single physical connection to Postgres backend.
@@ -45,5 +46,7 @@ public interface Connection extends QueryExecutor {
4546
*/
4647
CompletableFuture<Listening> subscribe(String channel, Consumer<String> onNotification);
4748

49+
CompletableFuture<Transaction> begin();
50+
4851
CompletableFuture<Void> close();
4952
}

src/main/java/com/pgasync/QueryExecutor.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
*/
1919
public interface QueryExecutor {
2020

21-
/**
22-
* Begins a transaction.
23-
*/
24-
CompletableFuture<Transaction> begin();
25-
2621
/**
2722
* Sends parameter less query script. The script may be multi query. Queries are separated with semicolons.
2823
* Accumulates fetched columns, rows and affected rows counts into memory and transforms them into a ResultSet when each {@link ResultSet} is fetched.

src/main/java/com/pgasync/Transaction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.pgasync;
1616

1717
import java.util.concurrent.CompletableFuture;
18+
import java.util.function.Function;
1819

1920
/**
2021
* A unit of work. Transactions must be committed or rolled back, otherwise a
@@ -45,4 +46,6 @@ public interface Transaction extends QueryExecutor {
4546
*/
4647
Connection getConnection();
4748

49+
CompletableFuture<Transaction> begin();
50+
4851
}

0 commit comments

Comments
 (0)
0