Skip to content
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
1 change: 1 addition & 0 deletions app/api/monolith-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ dependencies {
implementation project(':app:consumer:mathrank-contents-consumer-monolith')

implementation project(':common:mathrank-cache-caffeine')
implementation project(':common:mathrank-lazy-connection')
}
3 changes: 3 additions & 0 deletions common/mathrank-lazy-connection/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package kr.co.mathrank.common.lazyconnection;

import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;

import com.zaxxer.hikari.HikariDataSource;

@Configuration
class LazyConnectionDataSourceProxyConfiguration {
Comment thread
huhdy32 marked this conversation as resolved.
@Bean
HikariDataSource hikariDataSource(final DataSourceProperties dataSourceProperties) {
return dataSourceProperties.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}

@Bean
@Primary
DataSource lazyConnectionDataSource(final HikariDataSource hikariDataSource) {
return new LazyConnectionDataSourceProxy(hikariDataSource);
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ include(
'domain:mathrank-point-domain',

'common',
'common:mathrank-lazy-connection',
'common:mathrank-cache',
'common:mathrank-cache-redis',
'common:mathrank-cache-caffeine',
Expand Down