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

Reactive datasource config: cache-prepared-statements is not specific to any DB #9644

Merged
merged 2 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
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 @@ -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