Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add an option to have a simpler JDBI execution threadpool #4355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import ai.verta.modeldb.common.futures.InternalJdbi;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.sql.DataSource;
import org.jdbi.v3.core.Jdbi;

Expand All @@ -19,6 +21,15 @@ public static FutureJdbi initializeFutureJdbi(
return new FutureJdbi(jdbi, dbExecutor);
}

public static FutureJdbi initializeFutureJdbiWithFixedThreadpool(
DataSource dataSource, int poolSize) {
var jdbi = new InternalJdbi(Jdbi.create(dataSource));

ExecutorService executor = Executors.newFixedThreadPool(poolSize);
var dbExecutor = FutureExecutor.makeCompatibleExecutor(executor, "jdbi");
return new FutureJdbi(jdbi, dbExecutor);
}

public static DataSource initializeDataSource(DatabaseConfig databaseConfig, String poolName) {
final var hikariDataSource = new HikariDataSource();
final var dbUrl = RdbConfig.buildDatabaseConnectionString(databaseConfig.getRdbConfiguration());
Expand Down
Loading