Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
switch from cloud connectors to cfenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Gstoehl committed Dec 14, 2022
1 parent ebc909e commit 046a9d2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<version>${spring-cloud-connectors-version}</version>
</dependency>
<groupId>io.pivotal.cfenv</groupId>
<artifactId>java-cfenv-boot</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public abstract class WsBaseConfig {
@Value("${ws.rate-limit:10}")
private int rateLimit;

public abstract DataSource dataSource();

public abstract Flyway flyway();
public abstract Flyway flyway(DataSource dataSource);

public abstract BitClient bitClient(
ClientRegistrationRepository clientRegistration, ObjectMapper objectMapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
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.Profile;
Expand Down Expand Up @@ -49,25 +46,10 @@ public class WsCloudConfig extends WsBaseConfig {

@Bean
@Override
public DataSource 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
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql_cluster")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public DataSource dataSource() {

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ public class TestConfig extends WsBaseConfig {

@Autowired DataSource dataSource;

@Override
public DataSource dataSource() {
return dataSource;
}

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
final var flyway =
Flyway.configure()
.dataSource(dataSource)
Expand Down
1 change: 0 additions & 1 deletion ch-covidcertificate-backend-transformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

<spring-boot-version>2.7.3</spring-boot-version>
<spring-cloud-sleuth-version>3.1.3</spring-cloud-sleuth-version>
<spring-cloud-connectors-version>2.2.13.RELEASE</spring-cloud-connectors-version>
<testcontainers-version>1.17.3</testcontainers-version>
<shedlock-version>4.41.0</shedlock-version>

Expand Down

0 comments on commit 046a9d2

Please sign in to comment.