Skip to content

Commit

Permalink
PgConnectionImpl does not need an options supplier for one-shot conne…
Browse files Browse the repository at this point in the history
…ctions

Follows-up on #1306

Signed-off-by: Thomas Segismont <[email protected]>
  • Loading branch information
tsegismont committed Apr 21, 2023
1 parent d542a61 commit cc83994
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

package io.vertx.pgclient;

import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.impl.ContextInternal;
import io.vertx.pgclient.impl.PgConnectionImpl;
import io.vertx.sqlclient.SqlConnection;
import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.*;

/**
* A connection to Postgres.
Expand Down Expand Up @@ -52,7 +55,7 @@ public interface PgConnection extends SqlConnection {
* @return a future notified with the connection or the failure
*/
static Future<PgConnection> connect(Vertx vertx, PgConnectOptions options) {
return PgConnectionImpl.connect((ContextInternal) vertx.getOrCreateContext(), () -> options);
return PgConnectionImpl.connect((ContextInternal) vertx.getOrCreateContext(), options);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
import io.vertx.sqlclient.impl.SocketConnectionBase;
import io.vertx.sqlclient.impl.SqlConnectionBase;

import java.util.function.Supplier;

public class PgConnectionImpl extends SqlConnectionBase<PgConnectionImpl> implements PgConnection {

public static Future<PgConnection> connect(ContextInternal context, Supplier<PgConnectOptions> options) {
public static Future<PgConnection> connect(ContextInternal context, PgConnectOptions options) {
PgConnectionFactory client;
try {
client = new PgConnectionFactory(context.owner());
} catch (Exception e) {
return context.failedFuture(e);
}
return prepareForClose(context, client.connect(context, options.get())).map(PgConnection::cast);
return prepareForClose(context, client.connect(context, options)).map(PgConnection::cast);
}

private volatile Handler<PgNotification> notificationHandler;
Expand Down

0 comments on commit cc83994

Please sign in to comment.