Skip to content

Commit

Permalink
Merge pull request #60 from Project-Catcher/refact-hg-hikari
Browse files Browse the repository at this point in the history
refact: 히카리 db 설정 변경입니다.
  • Loading branch information
dev-khg authored Dec 23, 2023
2 parents 5e10e40 + 5c6bfca commit 408338a
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import com.catcher.infrastructure.utils.KmsUtils;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.util.Properties;

@Configuration
@RequiredArgsConstructor
Expand Down Expand Up @@ -71,10 +74,18 @@ public DataSource dataSource() throws Exception {
localPort
); // TODO: lport 값(현재 0)은 추후 서버 올릴때는 지정해줘야함

return DataSourceBuilder.create()
.url(kmsUtils.decrypt(databaseUrl).replace(Integer.toString(localPort), Integer.toString(assignedPort)))
.username(kmsUtils.decrypt(databaseUsername))
.password(kmsUtils.decrypt(databasePassword))
.build();

Properties properties = new Properties();
properties.setProperty("driverClassName", "org.mariadb.jdbc.Driver");
properties.setProperty("jdbcUrl", kmsUtils.decrypt(databaseUrl).replace(Integer.toString(localPort), Integer.toString(assignedPort)));
properties.setProperty("maxLifetime", "179000");
properties.setProperty("idleTimeout", "185000");
properties.setProperty("password", kmsUtils.decrypt(databasePassword));
properties.setProperty("username", kmsUtils.decrypt(databaseUsername));
properties.setProperty("leakDetectionThreshold", "60000");
properties.setProperty("maximumPoolSize", "20");
properties.setProperty("minimumIdle", "20");

return new HikariDataSource(new HikariConfig(properties));
}
}

0 comments on commit 408338a

Please sign in to comment.