Skip to content

Commit

Permalink
Issue ReactiveX#887: Merged spring cloud common with spring cloud 2 m…
Browse files Browse the repository at this point in the history
…odule (ReactiveX#899)
  • Loading branch information
Romeh committed Mar 3, 2020
1 parent 577025d commit b434731
Show file tree
Hide file tree
Showing 19 changed files with 223 additions and 317 deletions.
13 changes: 0 additions & 13 deletions resilience4j-spring-cloud-common/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions resilience4j-spring-cloud2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dependencies {
compile project(':resilience4j-spring-cloud-common')

compile project(':resilience4j-spring')
compile project(':resilience4j-spring-boot2')

compileOnly(libraries.spring_cloud_context2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,78 @@
package io.github.resilience4j.bulkhead.autoconfigure;

import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.bulkhead.BulkheadRegistry;
import io.github.resilience4j.bulkhead.ThreadPoolBulkhead;
import io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry;
import io.github.resilience4j.bulkhead.configure.BulkheadConfiguration;
import io.github.resilience4j.bulkhead.configure.BulkheadConfigurationProperties;
import io.github.resilience4j.bulkhead.configure.threadpool.ThreadPoolBulkheadConfiguration;
import io.github.resilience4j.bulkhead.event.BulkheadEvent;
import io.github.resilience4j.common.CompositeCustomizer;
import io.github.resilience4j.common.bulkhead.configuration.BulkheadConfigCustomizer;
import io.github.resilience4j.common.bulkhead.configuration.ThreadPoolBulkheadConfigCustomizer;
import io.github.resilience4j.common.bulkhead.configuration.ThreadPoolBulkheadConfigurationProperties;
import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.core.registry.RegistryEventConsumer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@ConditionalOnClass({Bulkhead.class, RefreshScope.class})
@AutoConfigureAfter(RefreshAutoConfiguration.class)
@AutoConfigureBefore(BulkheadAutoConfiguration.class)
public class RefreshScopedBulkheadAutoConfiguration extends
AbstractRefreshScopedBulkheadConfiguration {
public class RefreshScopedBulkheadAutoConfiguration {
protected final BulkheadConfiguration bulkheadConfiguration;
protected final ThreadPoolBulkheadConfiguration threadPoolBulkheadConfiguration;

protected RefreshScopedBulkheadAutoConfiguration() {
this.threadPoolBulkheadConfiguration = new ThreadPoolBulkheadConfiguration();
this.bulkheadConfiguration = new BulkheadConfiguration();
}

/**
* @param bulkheadConfigurationProperties bulkhead spring configuration properties
* @param bulkheadEventConsumerRegistry the bulkhead event consumer registry
* @return the RefreshScoped BulkheadRegistry
*/
@Bean
@org.springframework.cloud.context.config.annotation.RefreshScope
@ConditionalOnMissingBean
public BulkheadRegistry bulkheadRegistry(
BulkheadConfigurationProperties bulkheadConfigurationProperties,
EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry,
RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer,
@Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) {
return bulkheadConfiguration
.bulkheadRegistry(bulkheadConfigurationProperties, bulkheadEventConsumerRegistry,
bulkheadRegistryEventConsumer, compositeBulkheadCustomizer);
}

/**
* @param threadPoolBulkheadConfigurationProperties thread pool bulkhead spring configuration
* properties
* @param bulkheadEventConsumerRegistry the bulk head event consumer registry
* @return the RefreshScoped ThreadPoolBulkheadRegistry
*/
@Bean
@org.springframework.cloud.context.config.annotation.RefreshScope
@ConditionalOnMissingBean
public ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry(
ThreadPoolBulkheadConfigurationProperties threadPoolBulkheadConfigurationProperties,
EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry,
RegistryEventConsumer<ThreadPoolBulkhead> threadPoolBulkheadRegistryEventConsumer,
@Qualifier("compositeThreadPoolBulkheadCustomizer") CompositeCustomizer<ThreadPoolBulkheadConfigCustomizer> compositeThreadPoolBulkheadCustomizer) {

return threadPoolBulkheadConfiguration.threadPoolBulkheadRegistry(
threadPoolBulkheadConfigurationProperties, bulkheadEventConsumerRegistry,
threadPoolBulkheadRegistryEventConsumer, compositeThreadPoolBulkheadCustomizer);
}
}
Loading

0 comments on commit b434731

Please sign in to comment.