Skip to content

Commit 8dfd276

Browse files
authored
Created a resilience4j-framework-common module which hosts common cod… (ReactiveX#455)
* Created a resilience4j-framework-common module which hosts common code which is shared between Spring Boot 1, Spring Boot 2, Ratpack and in future Micronaut.
1 parent de3bfbe commit 8dfd276

File tree

61 files changed

+102
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+102
-687
lines changed

resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ List of available endpoints:
616616
Example of response:
617617
----
618618
{
619-
"eventsList": [
619+
"rateLimiterEvents": [
620620
{
621621
"rateLimiterName": "backendA",
622622
"type": "SUCCESSFUL_ACQUIRE",

resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot2.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ List of available endpoints:
754754
Example of response:
755755
----
756756
{
757-
"eventsList": [
757+
"rateLimiterEvents": [
758758
{
759759
"rateLimiterName": "backendA",
760760
"type": "SUCCESSFUL_ACQUIRE",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies {
2+
compile project(':resilience4j-core')
3+
compile project(':resilience4j-circuitbreaker')
4+
compile project(':resilience4j-ratelimiter')
5+
compile project(':resilience4j-retry')
6+
compile project(':resilience4j-bulkhead')
7+
}
8+
9+
ext.moduleName='io.github.resilience4j.framework-common'
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*/
1616
package io.github.resilience4j.bulkhead.monitoring.endpoint;
1717

18-
import com.fasterxml.jackson.annotation.JsonInclude;
1918
import io.github.resilience4j.bulkhead.event.BulkheadEvent;
2019

21-
@JsonInclude(JsonInclude.Include.NON_NULL)
2220
public class BulkheadEventDTO {
2321

2422
private String bulkheadName;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
import io.github.resilience4j.bulkhead.event.BulkheadEvent;
1919

20-
class BulkheadEventDTOFactory {
20+
public class BulkheadEventDTOFactory {
2121

2222
private BulkheadEventDTOFactory() {}
2323

24-
static BulkheadEventDTO createBulkheadEventDTOFactory(BulkheadEvent event){
24+
public static BulkheadEventDTO createBulkheadEventDTO(BulkheadEvent event){
2525
switch(event.getEventType()) {
2626
case CALL_PERMITTED:
2727
case CALL_REJECTED:
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
*/
1616
package io.github.resilience4j.circuitbreaker.monitoring.endpoint;
1717

18-
import com.fasterxml.jackson.annotation.JsonInclude;
1918
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
2019
import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent;
2120
import io.github.resilience4j.core.lang.Nullable;
2221

23-
@JsonInclude(JsonInclude.Include.NON_NULL)
2422
public class CircuitBreakerEventDTO {
2523

2624
@Nullable
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
import io.github.resilience4j.circuitbreaker.event.*;
1919

20-
class CircuitBreakerEventDTOFactory {
20+
public class CircuitBreakerEventDTOFactory {
2121

2222
private CircuitBreakerEventDTOFactory(){}
2323

24-
static CircuitBreakerEventDTO createCircuitBreakerEventDTO(CircuitBreakerEvent event){
24+
public static CircuitBreakerEventDTO createCircuitBreakerEventDTO(CircuitBreakerEvent event){
2525
switch(event.getEventType()) {
2626
case ERROR:
2727
CircuitBreakerOnErrorEvent onErrorEvent = (CircuitBreakerOnErrorEvent) event;
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
public class RateLimiterEndpointResponse {
2424

2525
@Nullable
26-
private List<String> rateLimitersNames;
26+
private List<String> rateLimiters;
2727

2828
// created for spring to be able to construct POJO
2929
public RateLimiterEndpointResponse() {}
3030

31-
public RateLimiterEndpointResponse(@Nullable List<String> rateLimitersNames) {
32-
this.rateLimitersNames = rateLimitersNames;
31+
public RateLimiterEndpointResponse(@Nullable List<String> rateLimiters) {
32+
this.rateLimiters = rateLimiters;
3333
}
3434

3535
@Nullable
36-
public List<String> getRateLimitersNames() {
37-
return rateLimitersNames;
36+
public List<String> getRateLimiters() {
37+
return rateLimiters;
3838
}
3939

40-
public void setRateLimitersNames(@Nullable List<String> rateLimitersNames) {
41-
this.rateLimitersNames = rateLimitersNames;
40+
public void setRateLimiters(@Nullable List<String> rateLimiters) {
41+
this.rateLimiters = rateLimiters;
4242
}
4343
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
*/
1616
package io.github.resilience4j.ratelimiter.monitoring.endpoint;
1717

18-
import com.fasterxml.jackson.annotation.JsonInclude;
1918
import io.github.resilience4j.core.lang.Nullable;
2019
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
2120

22-
@JsonInclude(JsonInclude.Include.NON_NULL)
2321
public class RateLimiterEventDTO {
2422

2523
@Nullable private String rateLimiterName;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 Dan Maas
2+
* Copyright 2017 Bohdan Storozhuk
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.github.resilience4j.ratpack.ratelimiter.endpoint;
16+
package io.github.resilience4j.ratelimiter.monitoring.endpoint;
1717

1818
import io.github.resilience4j.core.lang.Nullable;
1919

@@ -27,7 +27,7 @@ public class RateLimiterEventsEndpointResponse {
2727
public RateLimiterEventsEndpointResponse() {
2828
}
2929

30-
public RateLimiterEventsEndpointResponse(List<RateLimiterEventDTO> rateLimiterEvents) {
30+
public RateLimiterEventsEndpointResponse(@Nullable List<RateLimiterEventDTO> rateLimiterEvents) {
3131
this.rateLimiterEvents = rateLimiterEvents;
3232
}
3333

@@ -36,7 +36,7 @@ public List<RateLimiterEventDTO> getRateLimiterEvents() {
3636
return rateLimiterEvents;
3737
}
3838

39-
public void setRateLimiterEvents(List<RateLimiterEventDTO> rateLimiterEvents) {
39+
public void setRateLimiterEvents(@Nullable List<RateLimiterEventDTO> rateLimiterEvents) {
4040
this.rateLimiterEvents = rateLimiterEvents;
4141
}
4242
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
*/
1616
package io.github.resilience4j.retry.monitoring.endpoint;
1717

18-
import com.fasterxml.jackson.annotation.JsonInclude;
1918
import io.github.resilience4j.retry.event.RetryEvent;
2019

2120
/**
2221
* Retry event data DTO which will be returned from the REST API
2322
*/
24-
@JsonInclude(JsonInclude.Include.NON_NULL)
2523
public class RetryEventDTO {
2624

2725
private String retryName;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
/**
2121
* retry event DTO factory
2222
*/
23-
class RetryEventDTOFactory {
23+
public class RetryEventDTOFactory {
2424

2525
private RetryEventDTOFactory() {
2626
}
2727

28-
static RetryEventDTO createRetryEventDTO(RetryEvent event) {
28+
public static RetryEventDTO createRetryEventDTO(RetryEvent event) {
2929
switch (event.getEventType()) {
3030
case ERROR:
3131
RetryOnErrorEvent onErrorEvent = (RetryOnErrorEvent) event;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
*/
1616
package io.github.resilience4j.retry.monitoring.endpoint;
1717

18+
import io.github.resilience4j.core.lang.Nullable;
19+
1820
import java.util.List;
1921

2022
/**
2123
* retry events DTP for rest API
2224
*/
2325
public class RetryEventsEndpointResponse {
26+
27+
@Nullable
2428
private List<RetryEventDTO> retryEvents;
2529

2630
public RetryEventsEndpointResponse() {
@@ -30,6 +34,7 @@ public RetryEventsEndpointResponse(List<RetryEventDTO> retryEvents) {
3034
this.retryEvents = retryEvents;
3135
}
3236

37+
@Nullable
3338
public List<RetryEventDTO> getRetryEvents() {
3439
return retryEvents;
3540
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class BulkheadEventDTOFactoryTest {
1414
public void shouldMapBulkheadOnCallFinishedEvent(){
1515
BulkheadOnCallFinishedEvent event = new BulkheadOnCallFinishedEvent("name");
1616

17-
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event);
17+
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event);
1818

1919
assertThat(eventDTO.getBulkheadName()).isEqualTo("name");
2020
assertThat(eventDTO.getType()).isEqualTo(CALL_FINISHED);
@@ -25,7 +25,7 @@ public void shouldMapBulkheadOnCallFinishedEvent(){
2525
public void shouldMapBulkheadOnCallPermittedEvent(){
2626
BulkheadOnCallPermittedEvent event = new BulkheadOnCallPermittedEvent("name");
2727

28-
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event);
28+
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event);
2929

3030
assertThat(eventDTO.getBulkheadName()).isEqualTo("name");
3131
assertThat(eventDTO.getType()).isEqualTo(CALL_PERMITTED);
@@ -36,7 +36,7 @@ public void shouldMapBulkheadOnCallPermittedEvent(){
3636
public void shouldMapBulkheadOnCallRejectedEvent(){
3737
BulkheadOnCallRejectedEvent event = new BulkheadOnCallRejectedEvent("name");
3838

39-
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event);
39+
BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event);
4040

4141
assertThat(eventDTO.getBulkheadName()).isEqualTo("name");
4242
assertThat(eventDTO.getType()).isEqualTo(CALL_REJECTED);

resilience4j-ratpack/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dependencies {
44
implementation ( libraries.groovy )
55
compileOnly ( libraries.ratpack )
66
compile project(':resilience4j-annotations')
7+
compile project(':resilience4j-framework-common')
78
compile project(':resilience4j-bulkhead')
89
compile project(':resilience4j-circuitbreaker')
910
compile project(':resilience4j-ratelimiter')

resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/Resilience4jModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
4646
import io.github.resilience4j.ratelimiter.event.RateLimiterEvent;
4747
import io.github.resilience4j.ratpack.bulkhead.BulkheadMethodInterceptor;
48-
import io.github.resilience4j.ratpack.bulkhead.endpoint.BulkheadChain;
48+
import io.github.resilience4j.ratpack.bulkhead.monitoring.endpoint.BulkheadChain;
4949
import io.github.resilience4j.ratpack.circuitbreaker.CircuitBreakerMethodInterceptor;
50-
import io.github.resilience4j.ratpack.circuitbreaker.endpoint.CircuitBreakerChain;
50+
import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.CircuitBreakerChain;
5151
import io.github.resilience4j.ratpack.ratelimiter.RateLimiterMethodInterceptor;
52-
import io.github.resilience4j.ratpack.ratelimiter.endpoint.RateLimiterChain;
52+
import io.github.resilience4j.ratpack.ratelimiter.monitoring.endpoint.RateLimiterChain;
5353
import io.github.resilience4j.ratpack.retry.RetryMethodInterceptor;
54-
import io.github.resilience4j.ratpack.retry.endpoint.RetryChain;
54+
import io.github.resilience4j.ratpack.retry.monitoring.endpoint.RetryChain;
5555
import io.github.resilience4j.retry.RetryConfig;
5656
import io.github.resilience4j.retry.RetryRegistry;
5757
import io.github.resilience4j.retry.annotation.Retry;

resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventDTO.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventsEndpointResponse.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)