Skip to content

Commit d92a752

Browse files
committed
feat(future): 提供更方便的executeFuture使用方法。
1 parent ce088a7 commit d92a752

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>cc.carm.lib</groupId>
77
<artifactId>easysql-parent</artifactId>
8-
<version>0.4.4</version>
8+
<version>0.4.5</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

api/src/main/java/cc/carm/lib/easysql/api/SQLAction.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Collections;
1313
import java.util.List;
1414
import java.util.UUID;
15+
import java.util.concurrent.CompletableFuture;
1516
import java.util.concurrent.Future;
1617
import java.util.concurrent.TimeUnit;
1718

@@ -207,7 +208,21 @@ default void executeAsync(@Nullable SQLHandler<T> success) {
207208
void executeAsync(@Nullable SQLHandler<T> success,
208209
@Nullable SQLExceptionHandler failure);
209210

210-
<R> @NotNull Future<R> executeFuture(@NotNull SQLFunction<T, R> handler);
211+
/**
212+
* 以异步Future方式执行SQL语句。
213+
*
214+
* @return 异步执行的Future实例,可通过 {@link Future#get()} 阻塞并等待结果。
215+
*/
216+
default @NotNull CompletableFuture<Void> executeFuture() {
217+
return executeFuture((t -> null));
218+
}
219+
220+
/**
221+
* 以异步Future方式执行SQL语句。
222+
*
223+
* @return 异步执行的Future实例,可通过 {@link Future#get()} 阻塞并等待结果。
224+
*/
225+
<R> @NotNull CompletableFuture<R> executeFuture(@NotNull SQLFunction<T, R> handler);
211226

212227
default void handleException(@Nullable SQLExceptionHandler handler, SQLException exception) {
213228
if (handler == null) handler = defaultExceptionHandler();

demo/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easysql-parent</artifactId>
77
<groupId>cc.carm.lib</groupId>
8-
<version>0.4.4</version>
8+
<version>0.4.5</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

impl/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easysql-parent</artifactId>
77
<groupId>cc.carm.lib</groupId>
8-
<version>0.4.4</version>
8+
<version>0.4.5</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

impl/src/main/java/cc/carm/lib/easysql/action/AbstractSQLAction.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.Objects;
1313
import java.util.UUID;
1414
import java.util.concurrent.CompletableFuture;
15-
import java.util.concurrent.Future;
1615
import java.util.concurrent.TimeUnit;
1716

1817
public abstract class AbstractSQLAction<T> implements SQLAction<T> {
@@ -95,7 +94,7 @@ public void executeAsync(SQLHandler<T> success, SQLExceptionHandler failure) {
9594
}
9695

9796
@Override
98-
public @NotNull <R> Future<R> executeFuture(@NotNull SQLFunction<T, R> handler) {
97+
public @NotNull <R> CompletableFuture<R> executeFuture(@NotNull SQLFunction<T, R> handler) {
9998
CompletableFuture<R> future = new CompletableFuture<>();
10099
executeAsync((t -> future.complete(handler.apply(t))), (e, q) -> future.completeExceptionally(e));
101100
return future;

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<groupId>cc.carm.lib</groupId>
2020
<artifactId>easysql-parent</artifactId>
2121
<packaging>pom</packaging>
22-
<version>0.4.4</version>
22+
<version>0.4.5</version>
2323

2424
<modules>
2525
<module>api</module>

with-pool/beecp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easysql-parent</artifactId>
77
<groupId>cc.carm.lib</groupId>
8-
<version>0.4.4</version>
8+
<version>0.4.5</version>
99
<relativePath>../../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

with-pool/hikaricp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easysql-parent</artifactId>
77
<groupId>cc.carm.lib</groupId>
8-
<version>0.4.4</version>
8+
<version>0.4.5</version>
99
<relativePath>../../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

0 commit comments

Comments
 (0)