use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.
the class DriverTestBase method testCreatePool05.
@Test
public void testCreatePool05(TestContext ctx) {
// The default options will be an instanceof the driver-specific class, so manually copy
// each option over onto a fresh generic options object to force the generic constructor path
SqlConnectOptions defaults = defaultOptions();
SqlConnectOptions opts = new SqlConnectOptions().setHost(defaults.getHost()).setPort(defaults.getPort()).setDatabase(defaults.getDatabase()).setUser(defaults.getUser()).setPassword(defaults.getPassword());
testCreatePool(ctx, () -> Pool.pool(opts));
}
use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.
the class DB2Driver method newPool.
@Override
public DB2Pool newPool(Vertx vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
VertxInternal vx = (VertxInternal) vertx;
PoolImpl pool;
if (options.isShared()) {
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
} else {
pool = newPoolImpl(vx, databases, options, closeFuture);
}
return new DB2PoolImpl(vx, closeFuture, pool);
}
use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.
the class DB2ConnectionAutoRetryTest method initialConnector.
@Override
protected void initialConnector(int proxyPort) {
SqlConnectOptions proxyOptions = new DB2ConnectOptions(options);
proxyOptions.setPort(proxyPort);
proxyOptions.setHost("localhost");
connectionConnector = ClientConfig.CONNECT.connect(vertx, proxyOptions);
poolConnector = ClientConfig.POOLED.connect(vertx, proxyOptions);
}
use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.
the class MySQLDriver method newPool.
@Override
public MySQLPool newPool(Vertx vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
VertxInternal vx = (VertxInternal) vertx;
PoolImpl pool;
if (options.isShared()) {
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
} else {
pool = newPoolImpl(vx, databases, options, closeFuture);
}
return new MySQLPoolImpl(vx, closeFuture, pool);
}
use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.
the class OracleDriver method newPoolImpl.
private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
OracleConnectOptions baseConnectOptions = OracleConnectOptions.wrap(databases.get(0));
QueryTracer tracer = vertx.tracer() == null ? null : new QueryTracer(vertx.tracer(), baseConnectOptions);
VertxMetrics vertxMetrics = vertx.metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(baseConnectOptions.getSocketAddress(), "sql", baseConnectOptions.getMetricsName()) : null;
Function<Connection, Future<Void>> afterAcquire = conn -> ((CommandHandler) conn).afterAcquire();
Function<Connection, Future<Void>> beforeRecycle = conn -> ((CommandHandler) conn).beforeRecycle();
PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, 1, options, afterAcquire, beforeRecycle, closeFuture);
List<ConnectionFactory> lst = databases.stream().map(o -> createConnectionFactory(vertx, o)).collect(Collectors.toList());
ConnectionFactory factory = ConnectionFactory.roundRobinSelector(lst);
pool.connectionProvider(factory::connect);
pool.init();
closeFuture.add(factory);
return pool;
}
Aggregations