mutinyPgPool(RuntimeValue(io.vertx.mutiny.pgclient.PgPool.newInstance(pgPool.getValue()));
}
- private PgPool initialize(Vertx vertx,
+ private PgPool initialize(VertxInternal vertx,
Integer eventLoopCount,
String dataSourceName,
DataSourceRuntimeConfig dataSourceRuntimeConfig,
@@ -75,15 +79,26 @@ private PgPool initialize(Vertx vertx,
DataSourceReactivePostgreSQLConfig dataSourceReactivePostgreSQLConfig) {
PoolOptions poolOptions = toPoolOptions(eventLoopCount, dataSourceRuntimeConfig, dataSourceReactiveRuntimeConfig,
dataSourceReactivePostgreSQLConfig);
- List pgConnectOptionsList = toPgConnectOptions(dataSourceRuntimeConfig,
+ List pgConnectOptionsList = toPgConnectOptions(dataSourceName, dataSourceRuntimeConfig,
dataSourceReactiveRuntimeConfig, dataSourceReactivePostgreSQLConfig);
- // Use the convention defined by Quarkus Micrometer Vert.x metrics to create metrics prefixed with postgresql.
- // and the client_name as tag.
- // See io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter.extractPrefix and
- // io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter.extractClientName
- pgConnectOptionsList.forEach(pgConnectOptions -> pgConnectOptions.setMetricsName("postgresql|" + dataSourceName));
+ Supplier> databasesSupplier = toDatabasesSupplier(vertx, pgConnectOptionsList,
+ dataSourceRuntimeConfig);
+ return createPool(vertx, poolOptions, pgConnectOptionsList, dataSourceName, databasesSupplier);
+ }
- return createPool(vertx, poolOptions, pgConnectOptionsList, dataSourceName);
+ private Supplier> toDatabasesSupplier(Vertx vertx, List pgConnectOptionsList,
+ DataSourceRuntimeConfig dataSourceRuntimeConfig) {
+ Supplier> supplier;
+ if (dataSourceRuntimeConfig.credentialsProvider.isPresent()) {
+ String beanName = dataSourceRuntimeConfig.credentialsProviderName.orElse(null);
+ CredentialsProvider credentialsProvider = CredentialsProviderFinder.find(beanName);
+ String name = dataSourceRuntimeConfig.credentialsProvider.get();
+ supplier = new ConnectOptionsSupplier<>(vertx, credentialsProvider, name, pgConnectOptionsList,
+ PgConnectOptions::new);
+ } else {
+ supplier = Utils.roundRobinSupplier(pgConnectOptionsList);
+ }
+ return supplier;
}
private PoolOptions toPoolOptions(Integer eventLoopCount,
@@ -116,7 +131,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
return poolOptions;
}
- private List toPgConnectOptions(DataSourceRuntimeConfig dataSourceRuntimeConfig,
+ private List toPgConnectOptions(String dataSourceName, DataSourceRuntimeConfig dataSourceRuntimeConfig,
DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig,
DataSourceReactivePostgreSQLConfig dataSourceReactivePostgreSQLConfig) {
List pgConnectOptionsList = new ArrayList<>();
@@ -166,8 +181,9 @@ private List toPgConnectOptions(DataSourceRuntimeConfig dataSo
pgConnectOptions.setSslMode(sslMode);
// If sslMode is verify-full, we also need a hostname verification algorithm
- if (sslMode == SslMode.VERIFY_FULL && (!dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm
- .isPresent() || "".equals(dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()))) {
+ if (sslMode == SslMode.VERIFY_FULL
+ && (!dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.isPresent()
+ || "".equals(dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()))) {
throw new IllegalArgumentException(
"quarkus.datasource.reactive.hostname-verification-algorithm must be specified under verify-full sslmode");
}
@@ -191,13 +207,20 @@ private List toPgConnectOptions(DataSourceRuntimeConfig dataSo
pgConnectOptions::setHostnameVerificationAlgorithm);
dataSourceReactiveRuntimeConfig.additionalProperties.forEach(pgConnectOptions::addProperty);
+
+ // Use the convention defined by Quarkus Micrometer Vert.x metrics to create metrics prefixed with postgresql.
+ // and the client_name as tag.
+ // See io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter.extractPrefix and
+ // io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter.extractClientName
+ pgConnectOptions.setMetricsName("postgresql|" + dataSourceName);
+
});
return pgConnectOptionsList;
}
private PgPool createPool(Vertx vertx, PoolOptions poolOptions, List pgConnectOptionsList,
- String dataSourceName) {
+ String dataSourceName, Supplier> databases) {
Instance instance;
if (DataSourceUtil.isDefault(dataSourceName)) {
instance = Arc.container().select(PgPoolCreator.class);
@@ -209,7 +232,7 @@ private PgPool createPool(Vertx vertx, PoolOptions poolOptions, List