Skip to content

Commit

Permalink
Issue ReactiveX#179: Initial Spring Boot 2.0 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Winkler committed Mar 16, 2018
1 parent 07007a6 commit afa27b7
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 110 deletions.
4 changes: 2 additions & 2 deletions libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
slf4jVersion = '1.7.24'
assertjVersion = '3.6.2'
logbackVersion = '0.9.26'
mockitoVersion = '1.10.19'
mockitoVersion = '2.15.0'
powermockVersion = '1.6.6'
jcacheVersion = '1.0.0'
awaitilityVersion = '1.7.0'
Expand Down Expand Up @@ -38,7 +38,7 @@ ext {
logback: "ch.qos.logback:logback-classic:${logbackVersion}",
mockito: "org.mockito:mockito-core:${mockitoVersion}",
powermock: "org.powermock:powermock:${powermockVersion}",
powermock_api_mockito: "org.powermock:powermock-api-mockito:${powermockVersion}",
powermock_api_mockito: "org.powermock:powermock-api-mockito2:${powermockVersion}",
powermock_module_junit4: "org.powermock:powermock-module-junit4:${powermockVersion}",
awaitility: "com.jayway.awaitility:awaitility:${awaitilityVersion}",
reactor_test: "io.projectreactor:reactor-test:${reactorVersion}",
Expand Down
6 changes: 1 addition & 5 deletions resilience4j-spring-boot2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ dependencies {
compile ( libraries.spring_boot2_actuator )
compile ( libraries.spring_boot2_web )
compile ( libraries.spring_reactor )
compile project(':resilience4j-micrometer')
compile project(':resilience4j-circuitbreaker')
compile project(':resilience4j-ratelimiter')
compile project(':resilience4j-consumer')
compileOnly project(':resilience4j-prometheus')
compileOnly project(':resilience4j-metrics')
testCompile ( libraries.spring_boot2_test )
testCompile project(':resilience4j-prometheus')
testCompile project(':resilience4j-metrics')
testCompile ( libraries.prometheus_spring_boot )
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@
*/
package io.github.resilience4j.circuitbreaker.autoconfigure;

import com.codahale.metrics.MetricRegistry;

import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.github.resilience4j.metrics.CircuitBreakerMetrics;
import io.github.resilience4j.micrometer.CircuitBreakerMetrics;
import io.micrometer.core.instrument.MeterRegistry;

/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* Auto-configuration} for resilience4j-metrics.
*/
@Configuration
@ConditionalOnClass(MeterRegistry.class)
@ConditionalOnClass(MetricsAutoConfiguration.class)
@AutoConfigureAfter(value = {CircuitBreakerAutoConfiguration.class, MetricsAutoConfiguration.class})
public class CircuitBreakerMetricsAutoConfiguration {

@Bean
public CircuitBreakerMetrics registerCircuitBreakerMetrics(CircuitBreakerRegistry circuitBreakerRegistry, MetricRegistry metricRegistry){
public CircuitBreakerMetrics registerCircuitBreakerMetrics(CircuitBreakerRegistry circuitBreakerRegistry, MeterRegistry meterRegistry){
CircuitBreakerMetrics circuitBreakerMetrics = CircuitBreakerMetrics.ofCircuitBreakerRegistry(circuitBreakerRegistry);
metricRegistry.registerAll(circuitBreakerMetrics);
circuitBreakerMetrics.bindTo(meterRegistry);
return circuitBreakerMetrics;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
*/
package io.github.resilience4j.ratelimiter.autoconfigure;

import com.codahale.metrics.MetricRegistry;

import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerAutoConfiguration;
import io.github.resilience4j.metrics.RateLimiterMetrics;
import io.github.resilience4j.micrometer.RateLimiterMetrics;
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import io.micrometer.core.instrument.MeterRegistry;

Expand All @@ -33,13 +31,13 @@
* Auto-configuration} for resilience4j-metrics.
*/
@Configuration
@ConditionalOnClass(MeterRegistry.class)
@ConditionalOnClass(MetricsAutoConfiguration.class)
@AutoConfigureAfter(value = {CircuitBreakerAutoConfiguration.class, MetricsAutoConfiguration.class})
public class RateLimiterMetricsAutoConfiguration {
@Bean
public RateLimiterMetrics registerRateLimiterMetrics(RateLimiterRegistry rateLimiterRegistry, MetricRegistry metricRegistry) {
public RateLimiterMetrics registerRateLimiterMetrics(RateLimiterRegistry rateLimiterRegistry, MeterRegistry meterRegistry) {
RateLimiterMetrics rateLimiterMetrics = RateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry);
metricRegistry.registerAll(rateLimiterMetrics);
rateLimiterMetrics.bindTo(meterRegistry);
return rateLimiterMetrics;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerAutoConfiguration,\
io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerMetricsAutoConfiguration,\
io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerPrometheusAutoConfiguration,\
io.github.resilience4j.ratelimiter.autoconfigure.RateLimiterAutoConfiguration,\
io.github.resilience4j.ratelimiter.autoconfigure.RateLimiterMetricsAutoConfiguration,\
io.github.resilience4j.ratelimiter.autoconfigure.RateLimiterPrometheusAutoConfiguration
io.github.resilience4j.ratelimiter.autoconfigure.RateLimiterMetricsAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public void testCircuitBreakerAutoConfiguration() throws IOException {

// Test Actuator endpoints

ResponseEntity<CircuitBreakerEndpointResponse> circuitBreakerList = restTemplate.getForEntity("/circuitbreaker", CircuitBreakerEndpointResponse.class);
ResponseEntity<CircuitBreakerEndpointResponse> circuitBreakerList = restTemplate.getForEntity("/actuator/circuitbreaker", CircuitBreakerEndpointResponse.class);
assertThat(circuitBreakerList.getBody().getCircuitBreakers()).hasSize(2).containsExactly("backendA", "backendB");


ResponseEntity<CircuitBreakerEventsEndpointResponse> circuitBreakerEventList = restTemplate.getForEntity("/circuitbreaker/events", CircuitBreakerEventsEndpointResponse.class);
ResponseEntity<CircuitBreakerEventsEndpointResponse> circuitBreakerEventList = restTemplate.getForEntity("/actuator/circuitbreaker/events", CircuitBreakerEventsEndpointResponse.class);
assertThat(circuitBreakerEventList.getBody().getCircuitBreakerEvents()).hasSize(2);

assertThat(circuitBreakerAspect.getOrder()).isEqualTo(400);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testRateLimiterAutoConfiguration() throws IOException {
// Test Actuator endpoints

ResponseEntity<RateLimiterEndpointResponse> rateLimiterList = restTemplate
.getForEntity("/ratelimiter", RateLimiterEndpointResponse.class);
.getForEntity("/actuator/ratelimiter", RateLimiterEndpointResponse.class);

assertThat(rateLimiterList.getBody().getRateLimitersNames()).hasSize(2).containsExactly("backendA", "backendB");

Expand All @@ -106,7 +106,7 @@ public void testRateLimiterAutoConfiguration() throws IOException {
}

ResponseEntity<RateLimiterEventsEndpointResponse> rateLimiterEventList = restTemplate
.getForEntity("/ratelimiter/events", RateLimiterEventsEndpointResponse.class);
.getForEntity("/actuator/ratelimiter/events", RateLimiterEventsEndpointResponse.class);

List<RateLimiterEventDTO> eventsList = rateLimiterEventList.getBody().getEventsList();
assertThat(eventsList).isNotEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector;

/**
* @author bstorozhuk
*/
@SpringBootApplication(scanBasePackages = "io.github.resilience4j")
@EnableSpringBootMetricsCollector
@EnablePrometheusEndpoint
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
Expand Down

0 comments on commit afa27b7

Please sign in to comment.