-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from sazzeo/resilience4j
Resilience4j
- Loading branch information
Showing
17 changed files
with
79 additions
and
980 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -24,6 +24,7 @@ bin/ | |
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
.idea | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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
37 changes: 31 additions & 6 deletions
37
d-user-service/src/main/java/com/example/duserservice/config/Resilience4JConfig.java
This file contains 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 |
---|---|---|
@@ -1,22 +1,47 @@ | ||
package com.example.duserservice.config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; | ||
import io.github.resilience4j.timelimiter.TimeLimiterConfig; | ||
import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JCircuitBreakerFactory; | ||
import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JConfigBuilder; | ||
import org.springframework.cloud.client.circuitbreaker.Customizer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.time.Duration; | ||
|
||
|
||
@Configuration | ||
public class Resilience4JConfig { | ||
|
||
|
||
//얘를 만들게 되면 CircuitBreakerFactory에 자동 구현됨. | ||
//Customizer : | ||
@Bean | ||
public Customizer<Resilience4JCircuitBreakerFactory> globalCustomConfiguration() { | ||
|
||
CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom() | ||
.failureRateThreshold(4) | ||
.waitDurationInOpenState(Duration.ofMillis(1000)) | ||
.slidingWindowType(CircuitBreakerConfig.SlidingWindowType.COUNT_BASED) | ||
.slidingWindowSize(2) | ||
.build(); | ||
|
||
TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() | ||
.timeoutDuration(Duration.ofSeconds(4)) | ||
.build(); | ||
|
||
return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id) | ||
.timeLimiterConfig(timeLimiterConfig) | ||
.circuitBreakerConfig(circuitBreakerConfig) | ||
.build()); | ||
|
||
} | ||
|
||
// @Bean | ||
// public Customizer<Resilience4JCircuitBreakerFactory> globalCustomConfiguration() { | ||
// return factory -> factory.configureDefault(id->new Resilience4JConfigBuilder(id) | ||
// .timeLimiterConfig() | ||
// .circuitBreakerConfig(circuitBreakerConfig) | ||
// .build()); | ||
// | ||
// public Customizer<ObjectMapper> objectMapper() { | ||
// return factory -> new ObjectMapper(); | ||
// } | ||
|
||
} |
This file contains 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 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.