Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertx PgPool is deprecated since v4.5 #17

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading