Skip to content

Commit

Permalink
Merge pull request #17 from florian-tirard/vertx-pg-pool-deprecation
Browse files Browse the repository at this point in the history
Vertx PgPool is deprecated since v4.5
  • Loading branch information
larousso authored Oct 1, 2024
2 parents 8bbcc8e + 563d345 commit 50c6a30
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.Test;
import org.postgresql.ds.PGSimpleDataSource;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
import reactor.core.publisher.Flux;

Expand All @@ -41,7 +42,9 @@

public abstract class AbstractPgAsyncPoolTest {

private final PostgreSQLContainer<?> postgreSQLContainer = new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("14"));
private final PostgreSQLContainer<?> postgreSQLContainer = new PostgreSQLContainer<>(DockerImageName.parse("postgres")
.withTag("14"))
.waitingFor(Wait.forListeningPort());

private final static ObjectMapper mapper = new ObjectMapper();
private PgAsyncPool pgAsyncPool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import fr.maif.jooq.QueryResult;
import io.vavr.concurrent.Future;
import io.vertx.pgclient.PgPool;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.TransactionRollbackException;
import org.jooq.Configuration;
import org.jooq.DSLContext;
Expand All @@ -20,9 +21,9 @@

import static fr.maif.jooq.reactive.FutureConversions.fromVertx;

public class ReactivePgAsyncPool extends AbstractReactivePgAsyncClient<PgPool> implements PgAsyncPool {
public class ReactivePgAsyncPool extends AbstractReactivePgAsyncClient<Pool> implements PgAsyncPool {

public ReactivePgAsyncPool(PgPool client, Configuration configuration) {
public ReactivePgAsyncPool(Pool client, Configuration configuration) {
super(client, configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import fr.maif.jooq.reactor.impl.ReactorPgAsyncPool;
import io.vertx.pgclient.PgPool;
import org.jooq.Configuration;

import io.vertx.sqlclient.Pool;
import reactor.core.publisher.Mono;

import java.util.function.Function;
Expand All @@ -16,7 +18,7 @@ public interface PgAsyncPool extends PgAsyncClient, fr.maif.jooq.PgAsyncPool, Pg

Mono<PgAsyncTransaction> beginMono();

static PgAsyncPool create(PgPool client, Configuration configuration) {
static PgAsyncPool create(Pool client, Configuration configuration) {
ReactivePgAsyncPool pool = new ReactivePgAsyncPool(client, configuration);
return new ReactorPgAsyncPool(pool);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import fr.maif.jooq.reactive.ReactivePgAsyncPool;
import io.vertx.core.Vertx;
import io.vertx.pgclient.PgBuilder;
import io.vertx.pgclient.PgConnectOptions;
import io.vertx.pgclient.PgPool;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.PoolOptions;
import org.jooq.Configuration;
import org.jooq.SQLDialect;
Expand All @@ -17,7 +19,7 @@
public class ReactiveAsyncPoolTest extends AbstractPgAsyncPoolTest {

private static Vertx vertx = Vertx.vertx();
private PgPool pool;
private Pool pool;

@Override
public PgAsyncPool pgAsyncPool(PostgreSQLContainer<?> postgreSQLContainer) {
Expand All @@ -37,7 +39,11 @@ public PgAsyncPool pgAsyncPool(PostgreSQLContainer<?> postgreSQLContainer) {
.setUser(username)
.setPassword(password);
PoolOptions poolOptions = new PoolOptions().setMaxSize(3);
pool = PgPool.pool(vertx, options, poolOptions);
pool = PgBuilder.pool()
.using(vertx)
.connectingTo(options)
.with(poolOptions)
.build();
var connection = pool.getConnection().toCompletionStage().toCompletableFuture().join();
connection.close().toCompletionStage().toCompletableFuture().join();
return new ReactivePgAsyncPool(pool, jooqConfig);
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ PgConnectOptions options = new PgConnectOptions()
.setPassword(password);
PoolOptions poolOptions = new PoolOptions().setMaxSize(10);
Vertx vertx = Vertx.vertx();
PgPool client = PgPool.pool(vertx, options, poolOptions);
Pool client = PgBuilder.pool()
.using(vertx)
.connectingTo(options)
.with(poolOptions)
.build();

PgAsyncPool reactivePgAsyncPool = new ReactivePgAsyncPool(client, jooqConfig);
```
Expand Down

0 comments on commit 50c6a30

Please sign in to comment.