Skip to content

Commit

Permalink
[0.12.0-SNAPSHOT]
Browse files Browse the repository at this point in the history
ClickHouse module in progress
  • Loading branch information
GoodforGod committed Jul 19, 2024
1 parent 64b3ae2 commit d943f47
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private static Optional<JdbcConnection> getConnectionExternal() {
var db = Optional.ofNullable(System.getenv(EXTERNAL_TEST_CLICKHOUSE_DATABASE)).orElse("default");
if (url != null) {
if (host != null && port != null) {
return Optional.of(ClickhouseConnectionImpl.forJDBC(url, host, Integer.parseInt(port), null, null, db, user, password));
return Optional
.of(ClickhouseConnectionImpl.forJDBC(url, host, Integer.parseInt(port), null, null, db, user, password));
} else {
return Optional.of(ClickhouseConnectionImpl.forExternal(url, user, password));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package io.goodforgod.testcontainers.extensions.jdbc;

import java.io.FileWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.sql.Connection;
import java.util.List;
import java.util.Optional;
import liquibase.Contexts;
import liquibase.LabelExpression;
import liquibase.Liquibase;
Expand All @@ -13,13 +19,6 @@
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;

import java.io.FileWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.sql.Connection;
import java.util.List;
import java.util.Optional;

public final class ClickhouseLiquibaseJdbcMigrationEngine implements JdbcMigrationEngine, AutoCloseable {

private static final Logger logger = LoggerFactory.getLogger(ClickhouseLiquibaseJdbcMigrationEngine.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,23 @@ protected HikariDataSource createDataSource() {
hikariConfig.setMaximumPoolSize(25);
hikariConfig.setPoolName("jdbc-connection");
hikariConfig.setLeakDetectionThreshold(10000);
hikariConfig.setConnectionTimeout(10000);
hikariConfig.setInitializationFailTimeout(10000);
return new HikariDataSource(hikariConfig);
}

final HikariDataSource dataSource() {
if (dataSource == null) {
this.dataSource = createDataSource();
try {
this.dataSource = createDataSource();
} catch (Exception e) {
try {
Thread.sleep(1000);
this.dataSource = createDataSource();
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
}

return this.dataSource;
Expand Down

0 comments on commit d943f47

Please sign in to comment.