Search in sources :

Example 1 with EncryptionLevel

use of io.vertx.mssqlclient.impl.codec.EncryptionLevel in project vertx-sql-client by eclipse-vertx.

the class MSSQLConnectionFactory method connectOrRedirect.

private Future<Connection> connectOrRedirect(SocketAddress server, String username, String password, String database, EventLoopContext context, int redirections) {
    if (redirections > 1) {
        return context.failedFuture("The client can be redirected only once");
    }
    return netClient.connect(server).map(so -> createSocketConnection(so, context)).compose(conn -> conn.sendPreLoginMessage(clientConfigSsl).compose(encryptionLevel -> login(conn, username, password, database, encryptionLevel, context))).compose(connBase -> {
        MSSQLSocketConnection conn = (MSSQLSocketConnection) connBase;
        SocketAddress alternateServer = conn.getAlternateServer();
        if (alternateServer == null) {
            return context.succeededFuture(conn);
        }
        Promise<Void> closePromise = context.promise();
        conn.close(null, closePromise);
        return closePromise.future().transform(v -> connectOrRedirect(alternateServer, username, password, database, context, redirections + 1));
    });
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) ConnectionFactoryBase(io.vertx.sqlclient.impl.ConnectionFactoryBase) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) EncryptionLevel(io.vertx.mssqlclient.impl.codec.EncryptionLevel) Promise(io.vertx.core.Promise) ContextInternal(io.vertx.core.impl.ContextInternal) Context(io.vertx.core.Context) Future(io.vertx.core.Future) NetClientOptions(io.vertx.core.net.NetClientOptions) Connection(io.vertx.sqlclient.impl.Connection) EventLoopContext(io.vertx.core.impl.EventLoopContext) SqlConnection(io.vertx.sqlclient.SqlConnection) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) NetSocket(io.vertx.core.net.NetSocket) SocketAddress(io.vertx.core.net.SocketAddress) SocketAddress(io.vertx.core.net.SocketAddress)

Aggregations

Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 EventLoopContext (io.vertx.core.impl.EventLoopContext)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 NetClientOptions (io.vertx.core.net.NetClientOptions)1 NetSocket (io.vertx.core.net.NetSocket)1 SocketAddress (io.vertx.core.net.SocketAddress)1 NetSocketInternal (io.vertx.core.net.impl.NetSocketInternal)1 MSSQLConnectOptions (io.vertx.mssqlclient.MSSQLConnectOptions)1 EncryptionLevel (io.vertx.mssqlclient.impl.codec.EncryptionLevel)1 SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)1 SqlConnection (io.vertx.sqlclient.SqlConnection)1 Connection (io.vertx.sqlclient.impl.Connection)1 ConnectionFactoryBase (io.vertx.sqlclient.impl.ConnectionFactoryBase)1 QueryTracer (io.vertx.sqlclient.impl.tracing.QueryTracer)1