Search in sources :

Example 1 with MSSQLPool

use of io.vertx.mssqlclient.MSSQLPool in project vertx-sql-client by eclipse-vertx.

the class MSSQLDriver method newPool.

@Override
public MSSQLPool 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 MSSQLPoolImpl(vx, closeFuture, 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) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl) VertxInternal(io.vertx.core.impl.VertxInternal) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl)

Example 2 with MSSQLPool

use of io.vertx.mssqlclient.MSSQLPool in project vertx-sql-client by eclipse-vertx.

the class MSSQLClientExamples method configureFromDataObject.

public void configureFromDataObject(Vertx vertx) {
    // Data object
    MSSQLConnectOptions connectOptions = new MSSQLConnectOptions().setPort(1433).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
    // Pool Options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
    // Create the pool from the data object
    MSSQLPool pool = MSSQLPool.pool(vertx, connectOptions, poolOptions);
    pool.getConnection(ar -> {
    // Handling your connection
    });
}
Also used : MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Example 3 with MSSQLPool

use of io.vertx.mssqlclient.MSSQLPool in project vertx-sql-client by eclipse-vertx.

the class MSSQLClientExamples method connecting01.

public void connecting01() {
    // Connect options
    MSSQLConnectOptions connectOptions = new MSSQLConnectOptions().setPort(1433).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
    // Pool options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
    // Create the pooled client
    MSSQLPool client = MSSQLPool.pool(connectOptions, poolOptions);
}
Also used : MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Example 4 with MSSQLPool

use of io.vertx.mssqlclient.MSSQLPool in project quarkus by quarkusio.

the class MSSQLPoolRecorder method configureMSSQLPool.

public RuntimeValue<MSSQLPool> configureMSSQLPool(RuntimeValue<Vertx> vertx, Supplier<Integer> eventLoopCount, String dataSourceName, DataSourcesRuntimeConfig dataSourcesRuntimeConfig, DataSourcesReactiveRuntimeConfig dataSourcesReactiveRuntimeConfig, DataSourcesReactiveMSSQLConfig dataSourcesReactiveMSSQLConfig, ShutdownContext shutdown) {
    MSSQLPool mssqlPool = initialize(vertx.getValue(), eventLoopCount.get(), dataSourcesRuntimeConfig.getDataSourceRuntimeConfig(dataSourceName), dataSourcesReactiveRuntimeConfig.getDataSourceReactiveRuntimeConfig(dataSourceName), dataSourcesReactiveMSSQLConfig.getDataSourceReactiveRuntimeConfig(dataSourceName));
    shutdown.addShutdownTask(mssqlPool::close);
    return new RuntimeValue<>(mssqlPool);
}
Also used : RuntimeValue(io.quarkus.runtime.RuntimeValue) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Example 5 with MSSQLPool

use of io.vertx.mssqlclient.MSSQLPool in project quarkus by quarkusio.

the class ReactiveMSSQLDataSourcesHealthCheck method init.

@PostConstruct
protected void init() {
    ArcContainer container = Arc.container();
    DataSourcesHealthSupport excluded = container.instance(DataSourcesHealthSupport.class).get();
    Set<String> excludedNames = excluded.getExcludedNames();
    for (InstanceHandle<MSSQLPool> handle : container.select(MSSQLPool.class, Any.Literal.INSTANCE).handles()) {
        String poolName = getPoolName(handle.getBean());
        if (!excludedNames.contains(poolName)) {
            addPool(poolName, handle.get());
        }
    }
}
Also used : ArcContainer(io.quarkus.arc.ArcContainer) DataSourcesHealthSupport(io.quarkus.datasource.runtime.DataSourcesHealthSupport) MSSQLPool(io.vertx.mssqlclient.MSSQLPool) PostConstruct(javax.annotation.PostConstruct)

Aggregations

MSSQLPool (io.vertx.mssqlclient.MSSQLPool)10 MSSQLConnectOptions (io.vertx.mssqlclient.MSSQLConnectOptions)6 Vertx (io.vertx.core.Vertx)2 Collectors (java.util.stream.Collectors)2 ArcContainer (io.quarkus.arc.ArcContainer)1 DataSourcesHealthSupport (io.quarkus.datasource.runtime.DataSourcesHealthSupport)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1 AbstractVerticle (io.vertx.core.AbstractVerticle)1 DeploymentOptions (io.vertx.core.DeploymentOptions)1 CloseFuture (io.vertx.core.impl.CloseFuture)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 JsonObject (io.vertx.core.json.JsonObject)1 PemTrustOptions (io.vertx.core.net.PemTrustOptions)1 ClientMetrics (io.vertx.core.spi.metrics.ClientMetrics)1 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)1 Source (io.vertx.docgen.Source)1 MSSQLConnection (io.vertx.mssqlclient.MSSQLConnection)1 MSSQLConnectionFactory (io.vertx.mssqlclient.impl.MSSQLConnectionFactory)1 MSSQLConnectionImpl (io.vertx.mssqlclient.impl.MSSQLConnectionImpl)1