Skip to content

Commit

Permalink
Merge pull request #306 from DP-3T/feature/fix-interops-config
Browse files Browse the repository at this point in the history
fix interops datasource cloud config
  • Loading branch information
martinalig authored Sep 3, 2021
2 parents bdac9f1 + 973f893 commit 87b8288
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions dpppt-backend-sdk/dpppt-backend-sdk-interops/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<artifactId>spring-security-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<version>${spring-cloud-connectors-version}</version>
</dependency>

<!-- Springboot configuration processor -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,40 @@

package org.dpppt.backend.sdk.interops.config;

import java.util.Map;
import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.CloudFactory;
import org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig;
import org.springframework.cloud.service.relational.DataSourceConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

@Configuration
public abstract class WSCloudBaseConfig extends WSBaseConfig {

@Autowired @Lazy private DataSource dataSource;
@Value("${datasource.maximumPoolSize:5}")
int dataSourceMaximumPoolSize;

@Value("${datasource.connectionTimeout:30000}")
int dataSourceConnectionTimeout;

@Value("${datasource.leakDetectionThreshold:0}")
int dataSourceLeakDetectionThreshold;

@Bean
@Override
public DataSource dataSource() {
return dataSource;
PoolConfig poolConfig = new PoolConfig(dataSourceMaximumPoolSize, dataSourceConnectionTimeout);
DataSourceConfig dbConfig =
new DataSourceConfig(
poolConfig,
null,
null,
Map.of("leakDetectionThreshold", dataSourceLeakDetectionThreshold));
CloudFactory factory = new CloudFactory();
return factory.getCloud().getSingletonServiceConnector(DataSource.class, dbConfig);
}

@Bean
Expand Down
2 changes: 1 addition & 1 deletion dpppt-backend-sdk/dpppt-backend-sdk-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<version>2.0.7.RELEASE</version>
<version>${spring-cloud-connectors-version}</version>
</dependency>

<dependency>
Expand Down
1 change: 1 addition & 0 deletions dpppt-backend-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<protobuf-java-version>3.12.1</protobuf-java-version>
<spring-boot-version>2.4.5</spring-boot-version>
<testcontainers-version>1.15.2</testcontainers-version>
<spring-cloud-connectors-version>2.0.7.RELEASE</spring-cloud-connectors-version>

<itCoverageAgent></itCoverageAgent>

Expand Down

0 comments on commit 87b8288

Please sign in to comment.