-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Issue298 #339
Issue298 #339
Conversation
- Change tests to test autoconfigure instead of scanning the entire package name which isn't the same behavior. Also has fix for handling the generic EventConsumerRegistry beans for overriding. This had to bump up the spring boot 2 version to 2.1.x. For spring boot 1.x, it doesn't allow for overriding. We can adjust this if we don't want to upgrade.
# Conflicts: # resilience4j-spring/src/main/java/io/github/resilience4j/circuitbreaker/configure/CircuitBreakerConfigurationProperties.java
@jlaber can you please resolve the merge conflicts so we can play with ur PR ;) |
# Conflicts: # resilience4j-spring-boot/src/test/resources/application.yaml # resilience4j-spring-boot2/src/test/java/io/github/resilience4j/circuitbreaker/CircuitBreakerAutoConfigurationTest.java # resilience4j-spring-boot2/src/test/resources/application.yaml
@Romeh Thanks for the notification. I just merged in the conflicts. Please let me know what you think! |
Sry, could you rebase again ;) |
# Conflicts: # libraries.gradle # resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java # resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java # resilience4j-spring-boot/src/test/java/io/github/resilience4j/circuitbreaker/CircuitBreakerAutoConfigurationTest.java # resilience4j-spring-boot/src/test/resources/application.yaml # resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java # resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java # resilience4j-spring-boot2/src/test/java/io/github/resilience4j/circuitbreaker/CircuitBreakerAutoConfigurationTest.java
@RobWin - All merged in. Thanks. |
@@ -31,23 +32,23 @@ | |||
@Configuration | |||
public class CircuitBreakerConfiguration { | |||
|
|||
private final CircuitBreakerConfigurationProperties circuitBreakerProperties; | |||
private EventConsumerRegister eventConsumerRegister; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think EventConsumerRegister not needed to be class instance variable here
eventConsumerRegister = new EventConsumerRegister(eventConsumerRegistry); | ||
circuitBreakerRegistry.registerPostCreationConsumer( | ||
(circuitBreaker, config) -> eventConsumerRegister.registerEventConsumer(circuitBreaker, config)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use method reference eventConsumerRegister::registerEventConsumer for better readability
@@ -45,12 +48,28 @@ public void setCircuitBreakerAspectOrder(int circuitBreakerAspectOrder) { | |||
} | |||
|
|||
private BackendProperties getBackendProperties(String backend) { | |||
return backends.get(backend); | |||
BackendProperties properties = backends.get(backend); | |||
if(properties.getSharedConfigName() != null && !properties.getSharedConfigName().isEmpty() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we replace it with if(!StringUtils.isEmpty(backendProperties.getSharedConfigName())) { for better code readability
public CircuitBreakerConfig createCircuitBreakerConfigFromShared(String sharedConfig) { | ||
BackendProperties backendProperties = getSharedConfigProperties(sharedConfig); | ||
if(backendProperties.getSharedConfigName() == null) { | ||
return buildCircuitBreakerConfig(backendProperties).configurationName(sharedConfig).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remark as above
// Register a consumer to hook up any health indicators for circuit breakers after creation. This will catch ones that get | ||
// created beyond initially configured backends. | ||
circuitBreakerRegistry.registerPostCreationConsumer((circuitBreaker, config) -> createHeathIndicatorForCircuitBreaker(circuitBreaker, config)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use method reference here this::createHeathIndicatorForCircuitBreaker
circuitBreakerConfiguration.registerPostCreationEventConsumer(circuitBreakerRegistry, eventConsumerRegistry); | ||
// Register a consumer to hook up any health indicators for circuit breakers after creation. This will catch ones that get | ||
// created beyond initially configured backends. | ||
circuitBreakerRegistry.registerPostCreationConsumer((circuitBreaker, config) -> createHeathIndicatorForCircuitBreaker(circuitBreaker, config)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use method reference here this::createHeathIndicatorForCircuitBreaker
* @param eventConsumerRegistry The event consumer registry. | ||
*/ | ||
public void initializeBackends(CircuitBreakerRegistry circuitBreakerRegistry, | ||
EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventConsumerRegistry eventConsumerRegistry is unneeded dependency here
@jlaber i had small code comments there , can you please update them plus can u please add in spring boot 1 doc that we are not overriding Event consumer and finally add a some documentation to rate limiter that spring beans can be overridden there as well :) . @RobWin are we going to base our-self on spring boot 2.1.* for spring boot 2 starter ? |
@Romeh I already updated our master to use the latest Spring Boot 2.1.3.RELEASE and latest Spring 1.5.19.RELEASE |
@Romeh or @RobWin Are either of you familiar with that Spring Boot Asnyc Rety test that i have failing: I can't reproduce that at all when I run the tests. Does it have something to do with the Spring Context not cleaning up for it appropriately? I see the Spring Boot 2 version has a @DirtiesContext which isn't available for the Spring Boot 1. |
Yes I can fix it tomorrow |
@jlaber the test is fixed now on master , please re-base ur PR and also resolve the merge conflicts then i guess we will be good to GO :) |
# Conflicts: # resilience4j-micrometer/src/main/java/io/github/resilience4j/micrometer/tagged/TaggedAsyncRetryMetrics.java # resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerPrometheusAutoConfiguration.java # resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterPrometheusAutoConfiguration.java # resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerMetricsAutoConfiguration.java # resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterMetricsAutoConfiguration.java # resilience4j-spring/src/main/java/io/github/resilience4j/retry/configure/AsyncRetryAspect.java
@Romeh All merged in. |
# Conflicts: # resilience4j-spring-boot2/src/test/java/io/github/resilience4j/circuitbreaker/CircuitBreakerAutoConfigurationTest.java # resilience4j-spring/src/main/java/io/github/resilience4j/circuitbreaker/configure/CircuitBreakerAspect.java # resilience4j-spring/src/main/java/io/github/resilience4j/circuitbreaker/configure/CircuitBreakerConfiguration.java
# Conflicts: # resilience4j-spring/src/main/java/io/github/resilience4j/ratelimiter/configure/RateLimiterConfiguration.java
# Conflicts: # resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerMetricsAutoConfiguration.java # resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterMetricsAutoConfiguration.java
@Romeh @RobWin io.github.resilience4j.retry.RetryAutoConfigurationTest > testRetryAutoConfigurationAsync FAILED I seem to only see these out on the build server and seem to be sporadic. Locally these errors don't occur. Also, I was just wondering if you think this is a good PR in general and functionality is good? If so, would you please consider pulling the PR in. Because of the number of changes in the configuration files, it can be tough to keep up-to-date with the merge conflicts that come in from all the other new functionality. I don't want to accidentally break anything new because of missing something trying to resolve the merge. |
Yes, we are working again on fixing this test. |
Ok, cool. Thanks for the info. |
Good question, seems many people contributed commits to this PR and I always squash a PR before it is merged. Maybe Github uses the first commit to choose the contributor? |
But maybe you could update our Spring Boot documentation and I merge it so that you are also listed. |
For this change, I didn't just allow overriding the default, I allow for shared configurations. You could have many shared configurations, or just one default. You really can do it however you want. I also removed the creation of Health Indicators from the @PostConstruct and allow for registering post circuit breaker creation handling functions. This was done so that if you create circuit breakers beyond the config file, you will still automatically get health indicators created for them.
Also:
This contains the changes from pull request: #312 - I needed the ability to override the defaults to build this functionality. I fixed the issues that I mentioned in that PR. One key note is that I did bump the spring boot 2 version to 2.1.x to allow for overriding the event consumers. If we don't want that upgrade, I can change it back, and we just won't allow that overriding until we want to upgrade to 2.1.x