Search in sources :

Example 11 with SqlConnectOptions

use of io.vertx.sqlclient.SqlConnectOptions in project hibernate-reactive by hibernate.

the class TenantDependentPool method changeDbName.

/**
 * Returns a new {@link SqlConnectOptions} with the correct database name for the tenant identifier.
 */
private SqlConnectOptions changeDbName(SqlConnectOptions connectOptions, Tenant tenantId) {
    SqlConnectOptions newOptions = new SqlConnectOptions(connectOptions);
    newOptions.setDatabase(tenantId.getDbName());
    return newOptions;
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions)

Example 12 with SqlConnectOptions

use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    MSSQLConnectOptions baseConnectOptions = MSSQLConnectOptions.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;
    PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, 1, options, null, null, 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;
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) MSSQLConnectionUriParser(io.vertx.mssqlclient.impl.MSSQLConnectionUriParser) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) MSSQLConnectionFactory(io.vertx.mssqlclient.impl.MSSQLConnectionFactory) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) MSSQLConnectionImpl(io.vertx.mssqlclient.impl.MSSQLConnectionImpl) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) CloseFuture(io.vertx.core.impl.CloseFuture) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) MSSQLConnectionFactory(io.vertx.mssqlclient.impl.MSSQLConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl)

Example 13 with SqlConnectOptions

use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLConnectionAutoRetryTest method initialConnector.

@Override
protected void initialConnector(int proxyPort) {
    SqlConnectOptions proxyOptions = new MSSQLConnectOptions(options);
    proxyOptions.setPort(proxyPort);
    proxyOptions.setHost("localhost");
    connectionConnector = ClientConfig.CONNECT.connect(vertx, proxyOptions);
    poolConnector = ClientConfig.POOLED.connect(vertx, proxyOptions);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions)

Example 14 with SqlConnectOptions

use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.

the class PgDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    PgConnectOptions baseConnectOptions = PgConnectOptions.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;
    boolean pipelinedPool = options instanceof PgPoolOptions && ((PgPoolOptions) options).isPipelined();
    int pipeliningLimit = pipelinedPool ? baseConnectOptions.getPipeliningLimit() : 1;
    PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, pipeliningLimit, options, null, null, 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;
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) PgPool(io.vertx.pgclient.PgPool) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) CloseFuture(io.vertx.core.impl.CloseFuture) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) io.vertx.pgclient.impl(io.vertx.pgclient.impl) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 15 with SqlConnectOptions

use of io.vertx.sqlclient.SqlConnectOptions in project vertx-sql-client by eclipse-vertx.

the class PgDriver method newPool.

@Override
public PgPool 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 PgPoolImpl(vx, closeFuture, pool);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) PgPool(io.vertx.pgclient.PgPool) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) CloseFuture(io.vertx.core.impl.CloseFuture) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) io.vertx.pgclient.impl(io.vertx.pgclient.impl) VertxInternal(io.vertx.core.impl.VertxInternal) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Aggregations

SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)20 CloseFuture (io.vertx.core.impl.CloseFuture)11 ContextInternal (io.vertx.core.impl.ContextInternal)11 VertxInternal (io.vertx.core.impl.VertxInternal)11 Vertx (io.vertx.core.Vertx)10 JsonObject (io.vertx.core.json.JsonObject)10 ClientMetrics (io.vertx.core.spi.metrics.ClientMetrics)10 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)10 PoolOptions (io.vertx.sqlclient.PoolOptions)10 Connection (io.vertx.sqlclient.impl.Connection)10 PoolImpl (io.vertx.sqlclient.impl.PoolImpl)10 SqlConnectionInternal (io.vertx.sqlclient.impl.SqlConnectionInternal)10 QueryTracer (io.vertx.sqlclient.impl.tracing.QueryTracer)10 ConnectionFactory (io.vertx.sqlclient.spi.ConnectionFactory)10 Driver (io.vertx.sqlclient.spi.Driver)10 List (java.util.List)10 Collectors (java.util.stream.Collectors)10 DB2ConnectOptions (io.vertx.db2client.DB2ConnectOptions)3 MSSQLConnectOptions (io.vertx.mssqlclient.MSSQLConnectOptions)3 MySQLConnectOptions (io.vertx.mysqlclient.MySQLConnectOptions)3