package io.vertx.pgclient;
import io.vertx.pgclient.impl.PgPoolImpl;
import io.vertx.sqlclient.PoolOptions;
import io.vertx.sqlclient.SqlResult;
import io.vertx.sqlclient.RowSet;
import io.vertx.sqlclient.Row;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.Tuple;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import java.util.List;
import java.util.stream.Collector;
@VertxGen
public interface PgPool extends Pool {
static PgPool pool() {
return pool(PgConnectOptions.fromEnv(), new PoolOptions());
}
static PgPool pool(PoolOptions poolOptions) {
return pool(PgConnectOptions.fromEnv(), poolOptions);
}
static PgPool pool(String connectionUri) {
return pool(connectionUri, new PoolOptions());
}
static PgPool pool(String connectionUri, PoolOptions poolOptions) {
return pool(PgConnectOptions.fromUri(connectionUri), poolOptions);
}
static PgPool pool(Vertx vertx, PoolOptions poolOptions) {
return pool(vertx, PgConnectOptions.fromEnv(), poolOptions);
}
static PgPool pool(Vertx vertx, String connectionUri, PoolOptions poolOptions) {
return pool(vertx, PgConnectOptions.fromUri(connectionUri), poolOptions);
}
static PgPool pool(PgConnectOptions connectOptions, PoolOptions poolOptions) {
if (Vertx.currentContext() != null) {
throw new IllegalStateException("Running in a Vertx context => use PgPool#pool(Vertx, PgConnectOptions, PoolOptions) instead");
}
VertxOptions vertxOptions = new VertxOptions();
if (connectOptions.isUsingDomainSocket()) {
vertxOptions.setPreferNativeTransport(true);
}
Vertx vertx = Vertx.vertx(vertxOptions);
return new PgPoolImpl(vertx.getOrCreateContext(), true, connectOptions, poolOptions);
}
static PgPool pool(Vertx vertx, PgConnectOptions connectOptions, PoolOptions poolOptions) {
return new PgPoolImpl(vertx.getOrCreateContext(), false, connectOptions, poolOptions);
}
PgPool preparedQuery(String sql, Handler<AsyncResult<RowSet>> handler);
@GenIgnore
<R> PgPool preparedQuery(String sql, Collector<Row, ?, R> collector, Handler<AsyncResult<SqlResult<R>>> handler);
PgPool query(String sql, Handler<AsyncResult<RowSet>> handler);
@GenIgnore
<R> PgPool query(String sql, Collector<Row, ?, R> collector, Handler<AsyncResult<SqlResult<R>>> handler);
PgPool preparedQuery(String sql, Tuple arguments, Handler<AsyncResult<RowSet>> handler);
@GenIgnore
<R> PgPool preparedQuery(String sql, Tuple arguments, Collector<Row, ?, R> collector, Handler<AsyncResult<SqlResult<R>>> handler);
PgPool preparedBatch(String sql, List<Tuple> batch, Handler<AsyncResult<RowSet>> handler);
@GenIgnore
<R> PgPool preparedBatch(String sql, List<Tuple> batch, Collector<Row, ?, R> collector, Handler<AsyncResult<SqlResult<R>>> handler);
}