Skip to content

Commit

Permalink
Issue ReactiveX#571: Spring Boot 1 and Spring Boot 2 custom endpoints…
Browse files Browse the repository at this point in the history
… should not be mandatory. (ReactiveX#572)
  • Loading branch information
RobWin authored Aug 16, 2019
1 parent c5771c1 commit dcaeb44
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package io.github.resilience4j.bulkhead.autoconfigure;

import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.bulkhead.BulkheadRegistry;
import io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry;
import io.github.resilience4j.bulkhead.event.BulkheadEvent;
import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEndpoint;
import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEventsEndpoint;
import io.github.resilience4j.consumer.EventConsumerRegistry;
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
Expand All @@ -43,11 +43,13 @@
public class BulkheadAutoConfiguration {

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public BulkheadEndpoint bulkheadEndpoint(BulkheadRegistry bulkheadRegistry, ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry) {
return new BulkheadEndpoint(bulkheadRegistry, threadPoolBulkheadRegistry);
}

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public BulkheadEventsEndpoint bulkheadEventsEndpoint(EventConsumerRegistry<BulkheadEvent> eventConsumerRegistry) {
return new BulkheadEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.github.resilience4j.circuitbreaker.autoconfigure;

import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -42,11 +43,13 @@
public class CircuitBreakerAutoConfiguration {

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public CircuitBreakerEndpoint circuitBreakerEndpoint(CircuitBreakerRegistry circuitBreakerRegistry) {
return new CircuitBreakerEndpoint(circuitBreakerRegistry);
}

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public CircuitBreakerEventsEndpoint circuitBreakerEventsEndpoint(EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry) {
return new CircuitBreakerEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
*/
package io.github.resilience4j.ratelimiter.autoconfigure;

import javax.annotation.PostConstruct;

import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator;
import javax.annotation.PostConstruct;

/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
Expand All @@ -55,11 +55,13 @@ public RateLimiterAutoConfiguration(RateLimiterProperties rateLimiterProperties,
}

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public RateLimiterEndpoint rateLimiterEndpoint(RateLimiterRegistry rateLimiterRegistry) {
return new RateLimiterEndpoint(rateLimiterRegistry);
}

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public RateLimiterEventsEndpoint rateLimiterEventsEndpoint(EventConsumerRegistry<RateLimiterEvent> eventsConsumerRegistry) {
return new RateLimiterEventsEndpoint(eventsConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.github.resilience4j.retry.autoconfigure;

import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down Expand Up @@ -43,11 +44,13 @@
public class RetryAutoConfiguration {

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public RetryEndpoint retryEndpoint(RetryRegistry retryRegistry) {
return new RetryEndpoint(retryRegistry);
}

@Bean
@ConditionalOnClass(value = {Endpoint.class})
public RetryEventsEndpoint retryEventsEndpoint(EventConsumerRegistry<RetryEvent> eventConsumerRegistry) {
return new RetryEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -43,14 +44,17 @@
@Import({BulkheadConfigurationOnMissingBean.class, FallbackConfigurationOnMissingBean.class})
@AutoConfigureBefore(EndpointAutoConfiguration.class)
public class BulkheadAutoConfiguration {

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public BulkheadEndpoint bulkheadEndpoint(BulkheadRegistry bulkheadRegistry, ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry) {
return new BulkheadEndpoint(bulkheadRegistry, threadPoolBulkheadRegistry);
}

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public BulkheadEventsEndpoint bulkheadEventsEndpoint(EventConsumerRegistry<BulkheadEvent> eventConsumerRegistry) {
return new BulkheadEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
*/
package io.github.resilience4j.circuitbreaker.autoconfigure;

import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent;
import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEndpoint;
import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpoint;
import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent;
import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEndpoint;
import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpoint;
import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean;


/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
Expand All @@ -46,12 +46,14 @@ public class CircuitBreakerAutoConfiguration {

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public CircuitBreakerEndpoint circuitBreakerEndpoint(CircuitBreakerRegistry circuitBreakerRegistry) {
return new CircuitBreakerEndpoint(circuitBreakerRegistry);
}

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public CircuitBreakerEventsEndpoint circuitBreakerEventsEndpoint(EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry) {
return new CircuitBreakerEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
*/
package io.github.resilience4j.ratelimiter.autoconfigure;

import javax.annotation.PostConstruct;

import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import io.github.resilience4j.consumer.EventConsumerRegistry;
import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint;
import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator;
import javax.annotation.PostConstruct;

/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
Expand All @@ -58,12 +58,14 @@ public RateLimiterAutoConfiguration(RateLimiterProperties rateLimiterProperties,

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public RateLimiterEndpoint rateLimiterEndpoint(RateLimiterRegistry rateLimiterRegistry) {
return new RateLimiterEndpoint(rateLimiterRegistry);
}

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public RateLimiterEventsEndpoint rateLimiterEventsEndpoint(EventConsumerRegistry<RateLimiterEvent> eventConsumerRegistry) {
return new RateLimiterEventsEndpoint(eventConsumerRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.github.resilience4j.retry.autoconfigure;

import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -40,14 +41,17 @@
@EnableConfigurationProperties(RetryProperties.class)
@Import({RetryConfigurationOnMissingBean.class, FallbackConfigurationOnMissingBean.class})
public class RetryAutoConfiguration {

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public RetryEndpoint retryEndpoint(RetryRegistry retryRegistry) {
return new RetryEndpoint(retryRegistry);
}

@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass(value = {Endpoint.class})
public RetryEventsEndpoint retryEventsEndpoint(EventConsumerRegistry<RetryEvent> eventConsumerRegistry) {
return new RetryEventsEndpoint(eventConsumerRegistry);
}
Expand Down

0 comments on commit dcaeb44

Please sign in to comment.