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

Refactor/#123 #125

Closed
wants to merge 16 commits into from
54 changes: 21 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugins {
id 'java-library'
id 'org.springframework.boot' apply(false)
id 'io.spring.dependency-management'
id 'org.sonarqube' version '4.4.1.3373'

id 'org.sonarqube' version '4.4.1.3373' apply(false)
}

allprojects {
Expand All @@ -17,14 +16,6 @@ allprojects {
}


sonar {
properties {
property "sonar.projectKey", "CMC11th-Melly_Melly_Server"
property "sonar.organization", "cmc11th-melly"
property "sonar.host.url", "https://sonarcloud.io"
}
}

subprojects {
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
Expand All @@ -34,13 +25,24 @@ subprojects {
apply plugin: 'jacoco-report-aggregation'


sonar {
properties {
property "sonar.projectKey", "CMC11th-Melly_Melly_Server"
property "sonar.organization", "melly"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "/home/runner/work/Melly_Server/Melly_Server/core/core-api/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
}
}

bootJar.enabled = false // core-api 모듈 이외에는 모두 boot 되지 않는 모듈
jar.enabled = true // jar는 필요함

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudDependenciesVersion}"
}
}


jacoco {
toolVersion = '0.8.8'
}
Expand All @@ -50,7 +52,7 @@ subprojects {
// jacoco report 형식 및 경로 설정
reports {
html.required = true
csv.required = true
csv.required = false
xml.required = true
}

Expand All @@ -68,7 +70,7 @@ subprojects {
)
}

finalizedBy 'jacocoTestCoverageVerification'
finalizedBy 'jacocoTestCoverageVerification' // jacocoTestReport를 실행 후 jacocoTestCoverageVerification 실행
}

jacocoTestCoverageVerification {
Expand All @@ -88,13 +90,13 @@ subprojects {
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.00
minimum = 0.0
}

limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.00
minimum = 0.0
}

limit {
Expand All @@ -106,42 +108,28 @@ subprojects {
excludes = [] + Qdomains
}


}

}

sonar {
properties {
property 'sonar.core.codeCoveragePlugin', 'jacoco'
property 'sonar.coverage.jacoco.xmlReportPaths', "${project.buildDir}/reports/jacoco/testCodeCoverageReport/**.xml"
}
}
dependencies {

// Lombok
// lombok
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'


testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'

// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.17.2'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.8.0'
testImplementation "com.h2database:h2"

implementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
implementation 'org.springframework.restdocs:spring-restdocs-restassured'
implementation 'io.rest-assured:spring-mock-mvc'
}

bootJar.enabled = false
jar.enabled = true

test {
useJUnitPlatform()
finalizedBy 'jacocoTestReport' // test가 끝나면 jacocoTestReport를 실행합니다.
finalizedBy 'jacocoTestReport' // test가 끝나면 jacocoTestReport를 실행
}
}

Expand Down
10 changes: 10 additions & 0 deletions clients/client-auth/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
Client 기능만을 위한 모듈을 분리함으로써 외부 통신을 위한 의존성만 독립적으로 implementation 할 수 있습니다.
장점 :
- 다른 모듈의 의존성 변화에 영향을 받지 않으므로 모듈을 안정적으로 관리할 수 있습니다.
- Client 기능만을 위한 의존성만 남아서 관리가 편하고 쉽게 파악이 가능합니다.
- implementation은 compile 단계와 runtime 모두에 의존성이 들어옵니다. 즉, implementation한 의존성이 많아지면 compile시 시간이 오래 걸립니다.
client 기능에 필요한 의존성만 compile함으로 compile 시간이 단축됩니다.
*/
dependencies {

implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
Expand All @@ -13,4 +21,6 @@ dependencies {

// JSON
implementation 'com.fasterxml.jackson.core:jackson-databind'

testImplementation "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import cmc.mellyserver.clientauth.api.LoginClientResult;

/*
현재 Melly에서는 카카오, 네이버, 구글, 애플 OAuth를 사용하고 있습니다. 차후 OAuth는 얼마든지 추가될 수 있기에 확장성을 고려한 설계가 필요합니다.
따라서 LoginClient 인터페이스를 만들어서 구체 클라이언트들이 구현하도록 만들었습니다.
OAuth 리소스 서버로부터 데이터를 받아와야 하는 쪽에서는 누구에게 요청하는지 관심을 가지지 않아도 됩니다.
- support : 해당 클라이언트가 어떤 Provider인지 판별합니다
- getUserData : 실제 유저 데이터를 받아옵니다
*/
public interface LoginClient {

boolean supports(String provider);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package cmc.mellyserver.clientauth.api;

import cmc.mellyserver.clientauth.LoginClient;
import lombok.RequiredArgsConstructor;
import static cmc.mellyserver.clientauth.api.Provider.*;

import org.springframework.stereotype.Component;

import static cmc.mellyserver.clientauth.api.Provider.NAVER;
import cmc.mellyserver.clientauth.LoginClient;
import lombok.RequiredArgsConstructor;

/*
타 모듈은 Client 호출이 필요할때 xxClient 객체를 사용해서 호출하면 됩니다.
OpenFeign 인터페이스에 대한 접근은 패키지 내부로 숨겼습니다.
*/
@Component
@RequiredArgsConstructor
public class NaverClient implements LoginClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import cmc.mellyserver.clientauth.model.NaverResource;

/*
통신 클라이언트를 호출하는 작업은 OpenFeign 인터페이스가 아닌 NaverClient라는 객체를 통해 수행합니다.
OpenFeign 인터페이스에 대한 세부 구현은 package default 접근 지시자를 통해 예상치 못한 곳에서의 사용을 차단했습니다.
*/
@FeignClient(name = "naverLogin", url = "${client.oauth.uri.naver}")
interface NaverLoginApi {

Expand Down
8 changes: 4 additions & 4 deletions clients/client-auth/src/main/resources/client-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ resilience4j.circuitbreaker:
configs:
default:
slidingWindowType: COUNT_BASED
minimumNumberOfCalls: 7 # Circuit Open 여부를 판단하기 위해 실행해야 하는 최소 요청 횟수
slidingWindowSize: 10 # Circuit Open 여부를 체크하는 윈도우 크기
waitDurationInOpenState: 10s # Circuit이 Open 상태에 머무는 시간
minimumNumberOfCalls: 3 # Circuit Open 여부를 판단하기 위해 실행해야 하는 최소 요청 횟수
slidingWindowSize: 5 # Circuit Open 여부를 체크하는 윈도우 크기
waitDurationInOpenState: 5s # Circuit이 Open 상태에 머무는 시간

failureRateThreshold: 80 # 슬라이딩 윈도우 내에서 몇 %이상되면 Circuit을 Open할지 결정하는 비율

slowCallDurationThreshold: 3000 # 몇초동안 요청이 지속되면 슬로우 콜로 판별되는지 기준
slowCallDurationThreshold: 2000 # 몇초동안 요청이 지속되면 슬로우 콜로 판별되는지 기준
slowCallRateThreshold: 80 # 슬라이딩 윈도우 내 요청 중 몇 %이상 슬로우 콜이 발생하면 Circuit을 Open할지 결정하는 비율

permittedNumberOfCallsInHalfOpenState: 5 # Half Open 상태에서 상태 변화를 위해 테스트 해보는 요청 횟수
Expand Down
7 changes: 3 additions & 4 deletions core/core-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'org.asciidoctor.jvm.convert' version '3.3.2'
// Rest Docs는 API 문서화 & 테스트로만 필요합니다. 따라서 core-api 모듈에서만 플러그인을 사용하도록 만들었습니다.
}

bootJar.enabled = true
Expand All @@ -13,7 +12,6 @@ configurations {
asciidoctorExt
}


dependencies {

// Spring
Expand All @@ -22,6 +20,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

implementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
implementation 'org.springframework.restdocs:spring-restdocs-restassured'
implementation 'io.rest-assured:spring-mock-mvc'

// JWT
// 해당 라이브러리 또한 client-auth에서 implementation으로 사용 중이기에 compileOnly로 변경했습니다.
Expand Down Expand Up @@ -58,7 +59,6 @@ dependencies {
// Rest Docs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'


// Multi Module
implementation project(":storage:db-core")
implementation project(":storage:db-redis")
Expand All @@ -68,7 +68,6 @@ dependencies {
implementation project(":support:logging")
implementation project(":clients:client-auth")


jacocoAggregation project(":storage:db-core")
jacocoAggregation project(":storage:db-redis")
jacocoAggregation project(":infra:notification")
Expand Down
Loading
Loading