Skip to content

Commit

Permalink
Merge pull request #9644 from tsegismont/issue/9642
Browse files Browse the repository at this point in the history
Reactive datasource config: cache-prepared-statements is not specific to any DB
  • Loading branch information
Sanne authored Jun 22, 2020
2 parents 4f809fc + 93b91eb commit 847ed40
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
@ConfigRoot(name = "datasource.reactive", phase = ConfigPhase.RUN_TIME)
public class DataSourceReactiveRuntimeConfig {

/**
* Whether prepared statements should be cached on the client side.
*/
@ConfigItem(defaultValue = "false")
public boolean cachePreparedStatements;

/**
* The datasource URL.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ public class DataSourceReactiveMySQLConfig {

/**
* Whether prepared statements should be cached on the client side.
*
* @deprecated use {@code datasource.reactive.cache-prepared-statements} instead.
*/
@ConfigItem
@Deprecated
public Optional<Boolean> cachePreparedStatements;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
public class LegacyDataSourceReactiveMySQLConfig {

/**
* @deprecated use quarkus.datasource.reactive.mysql.cache-prepared-statements instead.
* @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead.
*/
@ConfigItem
@Deprecated
public Optional<Boolean> cachePreparedStatements;

/**
* @deprecated use quarkus.datasource.reactive.mysql.charset instead.
* @deprecated use {@code quarkus.datasource.reactive.mysql.charset} instead.
*/
@ConfigItem
@Deprecated
public Optional<String> charset;

/**
* @deprecated use quarkus.datasource.reactive.mysql.collation instead.
* @deprecated use {@code quarkus.datasource.reactive.mysql.collation} instead.
*/
@ConfigItem
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import java.util.Map;

import org.jboss.logging.Logger;

import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.credentials.CredentialsProvider;
import io.quarkus.credentials.runtime.CredentialsProviderFinder;
Expand All @@ -30,6 +32,9 @@
@Recorder
@SuppressWarnings("deprecation")
public class MySQLPoolRecorder {

private static final Logger log = Logger.getLogger(MySQLPoolRecorder.class);

public RuntimeValue<MySQLPool> configureMySQLPool(RuntimeValue<Vertx> vertx, BeanContainer container,
DataSourcesRuntimeConfig dataSourcesRuntimeConfig,
DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig,
Expand Down Expand Up @@ -119,8 +124,12 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo
}

if (dataSourceReactiveMySQLConfig.cachePreparedStatements.isPresent()) {
log.warn("datasource.reactive.mysql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead");
mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveMySQLConfig.cachePreparedStatements.get());
} else {
mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements);
}

if (dataSourceReactiveMySQLConfig.charset.isPresent()) {
mysqlConnectOptions.setCharset(dataSourceReactiveMySQLConfig.charset.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ public class DataSourceReactivePostgreSQLConfig {

/**
* Whether prepared statements should be cached on the client side.
*
* @deprecated use {@code datasource.reactive.cache-prepared-statements} instead.
*/
@ConfigItem
@Deprecated
public Optional<Boolean> cachePreparedStatements;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
public class LegacyDataSourceReactivePostgreSQLConfig {

/**
* @deprecated use quarkus.datasource.reactive.postgresql.cache-prepared-statements instead.
* @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead.
*/
@ConfigItem
@Deprecated
public Optional<Boolean> cachePreparedStatements;

/**
* @deprecated use quarkus.datasource.reactive.postgresql.pipelining-limit instead.
* @deprecated use {@code quarkus.datasource.reactive.postgresql.pipelining-limit} instead.
*/
@ConfigItem
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import java.util.Map;

import org.jboss.logging.Logger;

import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.credentials.CredentialsProvider;
import io.quarkus.credentials.runtime.CredentialsProviderFinder;
Expand All @@ -31,6 +33,8 @@
@SuppressWarnings("deprecation")
public class PgPoolRecorder {

private static final Logger log = Logger.getLogger(PgPoolRecorder.class);

public RuntimeValue<PgPool> configurePgPool(RuntimeValue<Vertx> vertx, BeanContainer container,
DataSourcesRuntimeConfig dataSourcesRuntimeConfig,
DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig,
Expand Down Expand Up @@ -121,8 +125,12 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu
}

if (dataSourceReactivePostgreSQLConfig.cachePreparedStatements.isPresent()) {
log.warn("datasource.reactive.postgresql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead");
pgConnectOptions.setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get());
} else {
pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements);
}

if (dataSourceReactivePostgreSQLConfig.pipeliningLimit.isPresent()) {
pgConnectOptions.setPipeliningLimit(dataSourceReactivePostgreSQLConfig.pipeliningLimit.getAsInt());
}
Expand Down

0 comments on commit 847ed40

Please sign in to comment.