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

Issue298 #339

Merged
merged 19 commits into from
Apr 16, 2019
Merged

Issue298 #339

merged 19 commits into from
Apr 16, 2019

Conversation

jlaber
Copy link

@jlaber jlaber commented Feb 14, 2019

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

devcateu and others added 8 commits January 1, 2019 13:55
- 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.
@coveralls
Copy link

coveralls commented Feb 14, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 3fa500f on paychex:issue298 into fe3bf59 on resilience4j:master.

# Conflicts:
#	resilience4j-spring/src/main/java/io/github/resilience4j/circuitbreaker/configure/CircuitBreakerConfigurationProperties.java
@Romeh
Copy link
Member

Romeh commented Mar 14, 2019

@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
@jlaber
Copy link
Author

jlaber commented Mar 16, 2019

@Romeh Thanks for the notification. I just merged in the conflicts. Please let me know what you think!

@RobWin
Copy link
Member

RobWin commented Mar 22, 2019

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
@jlaber
Copy link
Author

jlaber commented Mar 23, 2019

@RobWin - All merged in. Thanks.

@@ -31,23 +32,23 @@
@Configuration
public class CircuitBreakerConfiguration {

private final CircuitBreakerConfigurationProperties circuitBreakerProperties;
private EventConsumerRegister eventConsumerRegister;
Copy link
Member

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));
}
Copy link
Member

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() ) {
Copy link
Member

@Romeh Romeh Mar 26, 2019

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();
Copy link
Member

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));

Copy link
Member

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));
Copy link
Member

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) {
Copy link
Member

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

@Romeh
Copy link
Member

Romeh commented Mar 26, 2019

@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 ?

@RobWin
Copy link
Member

RobWin commented Mar 27, 2019

@Romeh I already updated our master to use the latest Spring Boot 2.1.3.RELEASE and latest Spring 1.5.19.RELEASE

@jlaber
Copy link
Author

jlaber commented Mar 27, 2019

@Romeh or @RobWin Are either of you familiar with that Spring Boot Asnyc Rety test that i have failing:
io.github.resilience4j.retry.RetryAutoConfigurationTest > testRetryAutoConfigurationAsync FAILED

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.

@RobWin
Copy link
Member

RobWin commented Mar 27, 2019

Yes I can fix it tomorrow

@Romeh
Copy link
Member

Romeh commented Mar 29, 2019

@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
@jlaber
Copy link
Author

jlaber commented Apr 2, 2019

@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
@jlaber
Copy link
Author

jlaber commented Apr 4, 2019

@Romeh @RobWin
The build is failing again on one of those Retry tests:

io.github.resilience4j.retry.RetryAutoConfigurationTest > testRetryAutoConfigurationAsync FAILED
org.junit.ComparisonFailure at RetryAutoConfigurationTest.java:146
2019-04-04 13:26:23.702 INFO 6356 --- [ Thread-108] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'

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.

@RobWin
Copy link
Member

RobWin commented Apr 4, 2019

Yes, we are working again on fixing this test.
We will first release 0.14.0 and then take us time to merge this PR.

@jlaber
Copy link
Author

jlaber commented Apr 4, 2019

Ok, cool. Thanks for the info.

@Romeh Romeh changed the base branch from master to spring-override April 16, 2019 12:15
@Romeh Romeh merged commit c418742 into resilience4j:spring-override Apr 16, 2019
@jlaber
Copy link
Author

jlaber commented May 1, 2019

Hi @Romeh @RobWin,

It's great to see that this got merged in! I was just wondering what might have happened because it doesn't look like I show up as a contributor to the project?

Thanks,
Jason

@RobWin
Copy link
Member

RobWin commented May 2, 2019

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?

@RobWin
Copy link
Member

RobWin commented May 2, 2019

But maybe you could update our Spring Boot documentation and I merge it so that you are also listed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants