-
Notifications
You must be signed in to change notification settings - Fork 0
feature/34-circuit-breaker-for-grpc #35
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
365f32d
feat ( #34 ) : RESILIENCE4J 의존성 추가
qkrwndnjs1075 2e1470d
feat ( #34 ) : RESILIENCE4J 의존성 추가
qkrwndnjs1075 10ce71b
feat ( #34 ) : RESILIENCE4J + Retry config 추가
qkrwndnjs1075 1cf6b8b
feat ( #34 ) : RESILIENCE4J extensions 추가
qkrwndnjs1075 57ebb8e
feat ( #34 ) : RESILIENCE4J extenstions 적용
qkrwndnjs1075 2c2efe1
feat ( #34 ) : 서킷 브레이커 테스트 컨트롤러
qkrwndnjs1075 f387985
chore ( #34 ) : DependencyVersions Netty 추가
coehgns 9f10a49
chore ( #34 ) : Dependencies Netty 추가
coehgns f15de21
fix ( #34 ) : build.gradle.kts에 netty 설정을 추가하여 netty 관련 에러 해결
coehgns 38ef85d
feat ( #34 ) : ResilienceConfig에 scheduleGrpcCircuitBreaker 추가
coehgns 85c7242
feat ( #34 ) : ResilienceConfig에 scheduleGrpcRetry 추가
coehgns 7d6616f
feat ( #34 ) : ScheduleGrpcClient에 executeGrpcCallWithResilience exte…
coehgns 9115ff2
chore ( #34 ) : GrantExamCodesUseCase에 누락된 kdoc 추가
coehgns 38307ff
refactor ( #34 ) : 코드 구조 수정
coehgns 60e0115
feat ( #34 ) : GrpcResilienceTestController에 Schedule Test 로직 추가
coehgns f4caf9b
chore ( #34 ) : 클래스 네임 수정
qkrwndnjs1075 96e90c2
Merge remote-tracking branch 'origin/feature/34-circuit-breaker-for-g…
qkrwndnjs1075 0a93e10
chore ( #34 ) : test Controller 삭제
qkrwndnjs1075 e5c32e1
fix ( #34 ) : import * 삭제 후 하나씩 import 하도록 변경
qkrwndnjs1075 76d94c6
refactor ( #34 ) : Retry 바깥 → CircuitBreaker 안쪽 순서로 수정
qkrwndnjs1075 889b173
fix ( #34 ) : Netty 의존성 삭제
qkrwndnjs1075 d8c2bd7
refactor ( #34 ) : ScheduleGrpcClient full back 실패 예외 던지지 않도록 수정
coehgns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...frastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/ResilienceConfig.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package hs.kr.entrydsm.application.global.config | ||
|
|
||
| import io.github.resilience4j.circuitbreaker.CircuitBreaker | ||
| import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry | ||
| import io.github.resilience4j.retry.Retry | ||
| import io.github.resilience4j.retry.RetryRegistry | ||
| import org.springframework.context.annotation.Bean | ||
| import org.springframework.context.annotation.Configuration | ||
|
|
||
| @Configuration | ||
| class ResilienceConfig( | ||
| private val circuitBreakerRegistry: CircuitBreakerRegistry, | ||
| private val retryRegistry: RetryRegistry | ||
| ) { | ||
|
|
||
| @Bean | ||
| fun userGrpcCircuitBreaker(): CircuitBreaker { | ||
| return circuitBreakerRegistry.circuitBreaker("user-grpc") | ||
| } | ||
|
|
||
| @Bean | ||
| fun statusGrpcCircuitBreaker(): CircuitBreaker { | ||
| return circuitBreakerRegistry.circuitBreaker("status-grpc") | ||
| } | ||
|
|
||
| @Bean | ||
| fun scheduleGrpcCircuitBreaker(): CircuitBreaker { | ||
| return circuitBreakerRegistry.circuitBreaker("schedule-grpc") | ||
| } | ||
|
|
||
| @Bean | ||
| fun userGrpcRetry(): Retry { | ||
| return retryRegistry.retry("user-grpc") | ||
| } | ||
|
|
||
| @Bean | ||
| fun statusGrpcRetry(): Retry { | ||
| return retryRegistry.retry("status-grpc") | ||
| } | ||
|
|
||
| @Bean | ||
| fun scheduleGrpcRetry(): Retry { | ||
| return retryRegistry.retry("schedule-grpc") | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...e/src/main/kotlin/hs/kr/entrydsm/application/global/extension/ResilienceGrpcExtensions.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package hs.kr.entrydsm.application.global.extension | ||
|
|
||
| import io.github.resilience4j.circuitbreaker.CircuitBreaker | ||
| import io.github.resilience4j.kotlin.circuitbreaker.executeSuspendFunction | ||
| import io.github.resilience4j.kotlin.retry.executeSuspendFunction | ||
| import io.github.resilience4j.retry.Retry | ||
| import kotlinx.coroutines.CancellationException | ||
| import org.slf4j.LoggerFactory | ||
|
|
||
| private val log = LoggerFactory.getLogger("ResilienceGrpcExtensions") | ||
|
|
||
| suspend fun <T> executeGrpcCallWithResilience( | ||
| retry: Retry, | ||
| circuitBreaker: CircuitBreaker, | ||
| fallback: suspend () -> T, | ||
| block: suspend () -> T | ||
| ): T = | ||
| try { | ||
| retry.executeSuspendFunction { | ||
| circuitBreaker.executeSuspendFunction(block) | ||
| } | ||
| } catch (ce: CancellationException) { | ||
| throw ce | ||
| } catch (e: Exception) { | ||
| log.warn("gRPC 호출 실패, fallback 실행: {}", e.toString()) | ||
| fallback() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.