package io.vertx.ext.asyncsql.impl;
import com.github.mauricio.async.db.Connection;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.asyncsql.PostgreSQLClient;
import io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool;
import io.vertx.ext.asyncsql.impl.pool.PostgresqlAsyncConnectionPool;
import io.vertx.ext.sql.SQLConnection;
import scala.concurrent.ExecutionContext;
public class PostgreSQLClientImpl extends BaseSQLClient {
private final PostgresqlAsyncConnectionPool pool;
public PostgreSQLClientImpl(Vertx vertx, JsonObject globalConfig) {
super(vertx, globalConfig);
pool = new PostgresqlAsyncConnectionPool(vertx, globalConfig, getConnectionConfiguration(
PostgreSQLClient.DEFAULT_HOST,
PostgreSQLClient.DEFAULT_PORT,
PostgreSQLClient.DEFAULT_DATABASE,
PostgreSQLClient.DEFAULT_USER,
PostgreSQLClient.DEFAULT_PASSWORD,
PostgreSQLClient.DEFAULT_CHARSET,
PostgreSQLClient.DEFAULT_CONNECT_TIMEOUT,
PostgreSQLClient.DEFAULT_TEST_TIMEOUT,
globalConfig));
}
@Override
protected AsyncConnectionPool pool() {
return pool;
}
@Override
protected SQLConnection createFromPool(Connection conn, AsyncConnectionPool pool, ExecutionContext ec) {
return new PostgreSQLConnectionImpl(conn, pool, ec);
}
}