Skip to content

Commit

Permalink
Merge pull request quarkusio#29258 from tomas1885/mysql_addtional_config
Browse files Browse the repository at this point in the history
Support setting Reactive MySql connection timeout and authentication plugin configuration
  • Loading branch information
cescoffier authored Nov 28, 2022
2 parents e069d9f + 41a955b commit 3d8fe99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.quarkus.reactive.mysql.client.runtime;

import java.util.Optional;
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.vertx.mysqlclient.MySQLAuthenticationPlugin;
import io.vertx.mysqlclient.SslMode;

@ConfigGroup
Expand Down Expand Up @@ -38,4 +40,17 @@ public class DataSourceReactiveMySQLConfig {
*/
@ConfigItem(defaultValueDocumentation = "disabled")
public Optional<SslMode> sslMode = Optional.empty();

/**
* Connection timeout in seconds
*/
@ConfigItem()
public OptionalInt connectionTimeout = OptionalInt.empty();

/**
* The authentication plugin the client should use.
* By default, it uses the plugin name specified by the server in the initial handshake packet.
*/
@ConfigItem(defaultValueDocumentation = "default")
public Optional<MySQLAuthenticationPlugin> authenticationPlugin = Optional.empty();
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
poolOptions.setEventLoopSize(Math.max(0, eventLoopCount));
}

if (dataSourceReactiveMySQLConfig.connectionTimeout.isPresent()) {
poolOptions.setConnectionTimeout(dataSourceReactiveMySQLConfig.connectionTimeout.getAsInt());
poolOptions.setConnectionTimeoutUnit(TimeUnit.SECONDS);
}

return poolOptions;
}

Expand Down Expand Up @@ -191,6 +196,10 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo
dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get());
}

if (dataSourceReactiveMySQLConfig.authenticationPlugin.isPresent()) {
mysqlConnectOptions.setAuthenticationPlugin(dataSourceReactiveMySQLConfig.authenticationPlugin.get());
}

dataSourceReactiveRuntimeConfig.additionalProperties.forEach(mysqlConnectOptions::addProperty);

return mysqlConnectOptions;
Expand Down

0 comments on commit 3d8fe99

Please sign in to comment.