use of io.mycat.proxy.handler.backend.BackendConCreateHandler in project Mycat2 by MyCATApache.
the class MySQLDatasourcePool method innerCreateCon.
private Future<MySQLClientSession> innerCreateCon() {
PromiseInternal<MySQLClientSession> promise = VertxUtil.newPromise();
new BackendConCreateHandler(this, promise);
return promise.flatMap(session -> {
synchronized (allSessions) {
allSessions.add(session);
}
MySQLDatasource datasource = session.getDatasource();
String sql = datasource.getInitSqlForProxy();
if (!StringUtil.isEmpty(sql)) {
PromiseInternal<MySQLClientSession> promiseInternal = VertxUtil.newPromise();
ResultSetHandler.DEFAULT.request(session, COM_QUERY, sql.getBytes(StandardCharsets.UTF_8), promiseInternal);
return promiseInternal.onFailure(event -> {
session.close(false, "initSql fail");
});
} else {
return Future.succeededFuture(session);
}
});
}
Aggregations