From 8dfd2768fa931a893de400208dd93f61789210ef Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Sun, 19 May 2019 10:26:17 +0200 Subject: [PATCH] =?UTF-8?q?Created=20a=20resilience4j-framework-common=20m?= =?UTF-8?q?odule=20which=20hosts=20common=20cod=E2=80=A6=20(#455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- .../asciidoc/addon_guides/springboot.adoc | 2 +- .../asciidoc/addon_guides/springboot2.adoc | 2 +- resilience4j-framework-common/build.gradle | 9 ++ .../endpoint/BulkheadEndpointResponse.java | 0 .../monitoring/endpoint/BulkheadEventDTO.java | 2 - .../endpoint/BulkheadEventDTOFactory.java | 4 +- .../BulkheadEventsEndpointResponse.java | 0 .../monitoring/endpoint/package-info.java | 0 .../CircuitBreakerEndpointResponse.java | 0 .../endpoint/CircuitBreakerEventDTO.java | 2 - .../CircuitBreakerEventDTOBuilder.java | 0 .../CircuitBreakerEventDTOFactory.java | 4 +- .../CircuitBreakerEventsEndpointResponse.java | 0 .../monitoring/endpoint/package-info.java | 0 .../endpoint/RateLimiterEndpointResponse.java | 14 +-- .../endpoint/RateLimiterEventDTO.java | 2 - .../RateLimiterEventsEndpointResponse.java | 8 +- .../monitoring/endpoint/package-info.java | 0 .../endpoint/RetryEndpointResponse.java | 0 .../monitoring/endpoint/RetryEventDTO.java | 2 - .../endpoint/RetryEventDTOBuilder.java | 0 .../endpoint/RetryEventDTOFactory.java | 4 +- .../endpoint/RetryEventsEndpointResponse.java | 5 + .../monitoring/endpoint/package-info.java | 0 .../endpoint/BulkheadEventDTOFactoryTest.java | 6 +- .../CircuitBreakerEventDTOFactoryTest.java | 0 .../endpoint/RateLimiterEventDTOTest.java | 0 .../endpoint/RetryEventDTOFactoryTest.java | 0 resilience4j-ratpack/build.gradle | 1 + .../ratpack/Resilience4jModule.java | 8 +- .../bulkhead/endpoint/BulkheadEventDTO.java | 72 ------------ .../BulkheadEventsEndpointResponse.java | 41 ------- .../endpoint/BulkheadChain.java | 16 +-- .../monitoring}/endpoint/package-info.java | 2 +- .../endpoint/CircuitBreakerEventDTO.java | 109 ------------------ .../CircuitBreakerEventDTOBuilder.java | 59 ---------- .../CircuitBreakerEventDTOFactory.java | 58 ---------- .../CircuitBreakerEventsEndpointResponse.java | 42 ------- .../endpoint/CircuitBreakerChain.java | 10 +- .../metrics/CircuitBreakerMetricsDTO.java | 2 +- .../endpoint/package-info.java | 2 +- .../states/CircuitBreakerStateDTO.java | 4 +- .../CircuitBreakerStatesEndpointResponse.java | 2 +- .../endpoint/RateLimiterEventDTO.java | 66 ----------- .../endpoint/RateLimiterChain.java | 4 +- .../monitoring}/endpoint/package-info.java | 2 +- .../ratpack/retry/endpoint/RetryEventDTO.java | 76 ------------ .../endpoint/RetryEventsEndpointResponse.java | 42 ------- .../{ => monitoring}/endpoint/RetryChain.java | 17 +-- .../monitoring}/endpoint/package-info.java | 2 +- .../endpoint/BulkheadChainSpec.groovy | 3 +- .../endpoint/CircuitBreakerChainSpec.groovy | 5 +- .../endpoint/RateLimiterChainSpec.groovy | 3 +- .../endpoint/RetryChainSpec.groovy | 11 +- resilience4j-spring-boot-common/build.gradle | 1 + .../RateLimiterEventsEndpointResponse.java | 42 ------- .../endpoint/BulkheadEventsEndpoint.java | 6 +- .../RateLimiterAutoConfigurationTest.java | 4 +- .../endpoint/BulkheadEventsEndpoint.java | 6 +- .../RateLimiterAutoConfigurationTest.java | 4 +- settings.gradle | 1 + 61 files changed, 102 insertions(+), 687 deletions(-) create mode 100644 resilience4j-framework-common/build.gradle rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEndpointResponse.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java (94%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java (91%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpointResponse.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/package-info.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEndpointResponse.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java (97%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOBuilder.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java (95%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventsEndpointResponse.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/package-info.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java (75%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java (95%) rename {resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter => resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring}/endpoint/RateLimiterEventsEndpointResponse.java (78%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/package-info.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEndpointResponse.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java (95%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOBuilder.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java (95%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java (93%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/package-info.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java (94%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/test/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactoryTest.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/test/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTOTest.java (100%) rename {resilience4j-spring-boot-common => resilience4j-framework-common}/src/test/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactoryTest.java (100%) delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventDTO.java delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventsEndpointResponse.java rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/{ => monitoring}/endpoint/BulkheadChain.java (90%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/{retry => bulkhead/monitoring}/endpoint/package-info.java (91%) delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTO.java delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOBuilder.java delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOFactory.java delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventsEndpointResponse.java rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/CircuitBreakerChain.java (93%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/metrics/CircuitBreakerMetricsDTO.java (97%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/package-info.java (90%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/states/CircuitBreakerStateDTO.java (90%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/states/CircuitBreakerStatesEndpointResponse.java (93%) delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventDTO.java rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/{ => monitoring}/endpoint/RateLimiterChain.java (96%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/{bulkhead => ratelimiter/monitoring}/endpoint/package-info.java (91%) delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventDTO.java delete mode 100644 resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventsEndpointResponse.java rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/{ => monitoring}/endpoint/RetryChain.java (90%) rename resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/{ratelimiter => retry/monitoring}/endpoint/package-info.java (91%) rename resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/{ => monitoring}/endpoint/BulkheadChainSpec.groovy (98%) rename resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/{ => monitoring}/endpoint/CircuitBreakerChainSpec.groovy (97%) rename resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/{ => monitoring}/endpoint/RateLimiterChainSpec.groovy (98%) rename resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/{ => monitoring}/endpoint/RetryChainSpec.groovy (95%) delete mode 100644 resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java diff --git a/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc b/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc index 89666c4745..b4a2be88ab 100644 --- a/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc +++ b/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc @@ -616,7 +616,7 @@ List of available endpoints: Example of response: ---- { - "eventsList": [ + "rateLimiterEvents": [ { "rateLimiterName": "backendA", "type": "SUCCESSFUL_ACQUIRE", diff --git a/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot2.adoc b/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot2.adoc index db080c1ac5..6993238e3b 100644 --- a/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot2.adoc +++ b/resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot2.adoc @@ -754,7 +754,7 @@ List of available endpoints: Example of response: ---- { - "eventsList": [ + "rateLimiterEvents": [ { "rateLimiterName": "backendA", "type": "SUCCESSFUL_ACQUIRE", diff --git a/resilience4j-framework-common/build.gradle b/resilience4j-framework-common/build.gradle new file mode 100644 index 0000000000..fae14dec18 --- /dev/null +++ b/resilience4j-framework-common/build.gradle @@ -0,0 +1,9 @@ +dependencies { + compile project(':resilience4j-core') + compile project(':resilience4j-circuitbreaker') + compile project(':resilience4j-ratelimiter') + compile project(':resilience4j-retry') + compile project(':resilience4j-bulkhead') +} + +ext.moduleName='io.github.resilience4j.framework-common' \ No newline at end of file diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEndpointResponse.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEndpointResponse.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java similarity index 94% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java index b1e90121ab..c13ef2218e 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTO.java @@ -15,10 +15,8 @@ */ package io.github.resilience4j.bulkhead.monitoring.endpoint; -import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.bulkhead.event.BulkheadEvent; -@JsonInclude(JsonInclude.Include.NON_NULL) public class BulkheadEventDTO { private String bulkheadName; diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java similarity index 91% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java index 6d9a211926..12ae5efa96 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactory.java @@ -17,11 +17,11 @@ import io.github.resilience4j.bulkhead.event.BulkheadEvent; -class BulkheadEventDTOFactory { +public class BulkheadEventDTOFactory { private BulkheadEventDTOFactory() {} - static BulkheadEventDTO createBulkheadEventDTOFactory(BulkheadEvent event){ + public static BulkheadEventDTO createBulkheadEventDTO(BulkheadEvent event){ switch(event.getEventType()) { case CALL_PERMITTED: case CALL_REJECTED: diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpointResponse.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpointResponse.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/package-info.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/package-info.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/package-info.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/package-info.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEndpointResponse.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEndpointResponse.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java similarity index 97% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java index 94927ecad9..f593c3c8c6 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTO.java @@ -15,12 +15,10 @@ */ package io.github.resilience4j.circuitbreaker.monitoring.endpoint; -import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.circuitbreaker.CircuitBreaker; import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent; import io.github.resilience4j.core.lang.Nullable; -@JsonInclude(JsonInclude.Include.NON_NULL) public class CircuitBreakerEventDTO { @Nullable diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOBuilder.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOBuilder.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOBuilder.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOBuilder.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java similarity index 95% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java index 41b64763a4..6fb68bae8b 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactory.java @@ -17,11 +17,11 @@ import io.github.resilience4j.circuitbreaker.event.*; -class CircuitBreakerEventDTOFactory { +public class CircuitBreakerEventDTOFactory { private CircuitBreakerEventDTOFactory(){} - static CircuitBreakerEventDTO createCircuitBreakerEventDTO(CircuitBreakerEvent event){ + public static CircuitBreakerEventDTO createCircuitBreakerEventDTO(CircuitBreakerEvent event){ switch(event.getEventType()) { case ERROR: CircuitBreakerOnErrorEvent onErrorEvent = (CircuitBreakerOnErrorEvent) event; diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventsEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventsEndpointResponse.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventsEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventsEndpointResponse.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/package-info.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/package-info.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/package-info.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/package-info.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java similarity index 75% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java index 58c435c1a0..1d9ae0edc1 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEndpointResponse.java @@ -23,21 +23,21 @@ public class RateLimiterEndpointResponse { @Nullable - private List rateLimitersNames; + private List rateLimiters; // created for spring to be able to construct POJO public RateLimiterEndpointResponse() {} - public RateLimiterEndpointResponse(@Nullable List rateLimitersNames) { - this.rateLimitersNames = rateLimitersNames; + public RateLimiterEndpointResponse(@Nullable List rateLimiters) { + this.rateLimiters = rateLimiters; } @Nullable - public List getRateLimitersNames() { - return rateLimitersNames; + public List getRateLimiters() { + return rateLimiters; } - public void setRateLimitersNames(@Nullable List rateLimitersNames) { - this.rateLimitersNames = rateLimitersNames; + public void setRateLimiters(@Nullable List rateLimiters) { + this.rateLimiters = rateLimiters; } } diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java similarity index 95% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java index 90ae5b3f50..e2cf2738f0 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTO.java @@ -15,11 +15,9 @@ */ package io.github.resilience4j.ratelimiter.monitoring.endpoint; -import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.core.lang.Nullable; import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; -@JsonInclude(JsonInclude.Include.NON_NULL) public class RateLimiterEventDTO { @Nullable private String rateLimiterName; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventsEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java similarity index 78% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventsEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java index 865e4eceaf..29f7fdcce8 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventsEndpointResponse.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Dan Maas + * Copyright 2017 Bohdan Storozhuk * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.resilience4j.ratpack.ratelimiter.endpoint; +package io.github.resilience4j.ratelimiter.monitoring.endpoint; import io.github.resilience4j.core.lang.Nullable; @@ -27,7 +27,7 @@ public class RateLimiterEventsEndpointResponse { public RateLimiterEventsEndpointResponse() { } - public RateLimiterEventsEndpointResponse(List rateLimiterEvents) { + public RateLimiterEventsEndpointResponse(@Nullable List rateLimiterEvents) { this.rateLimiterEvents = rateLimiterEvents; } @@ -36,7 +36,7 @@ public List getRateLimiterEvents() { return rateLimiterEvents; } - public void setRateLimiterEvents(List rateLimiterEvents) { + public void setRateLimiterEvents(@Nullable List rateLimiterEvents) { this.rateLimiterEvents = rateLimiterEvents; } } diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/package-info.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/package-info.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/package-info.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/package-info.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEndpointResponse.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEndpointResponse.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java similarity index 95% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java index cb136ab349..9abd597e2b 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTO.java @@ -15,13 +15,11 @@ */ package io.github.resilience4j.retry.monitoring.endpoint; -import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.retry.event.RetryEvent; /** * Retry event data DTO which will be returned from the REST API */ -@JsonInclude(JsonInclude.Include.NON_NULL) public class RetryEventDTO { private String retryName; diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOBuilder.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOBuilder.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOBuilder.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOBuilder.java diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java similarity index 95% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java index 9c4c1c871f..e5c714fee6 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactory.java @@ -20,12 +20,12 @@ /** * retry event DTO factory */ -class RetryEventDTOFactory { +public class RetryEventDTOFactory { private RetryEventDTOFactory() { } - static RetryEventDTO createRetryEventDTO(RetryEvent event) { + public static RetryEventDTO createRetryEventDTO(RetryEvent event) { switch (event.getEventType()) { case ERROR: RetryOnErrorEvent onErrorEvent = (RetryOnErrorEvent) event; diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java similarity index 93% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java index e585b51e04..129113e652 100644 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java +++ b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventsEndpointResponse.java @@ -15,12 +15,16 @@ */ package io.github.resilience4j.retry.monitoring.endpoint; +import io.github.resilience4j.core.lang.Nullable; + import java.util.List; /** * retry events DTP for rest API */ public class RetryEventsEndpointResponse { + + @Nullable private List retryEvents; public RetryEventsEndpointResponse() { @@ -30,6 +34,7 @@ public RetryEventsEndpointResponse(List retryEvents) { this.retryEvents = retryEvents; } + @Nullable public List getRetryEvents() { return retryEvents; } diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/package-info.java b/resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/package-info.java similarity index 100% rename from resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/package-info.java rename to resilience4j-framework-common/src/main/java/io/github/resilience4j/retry/monitoring/endpoint/package-info.java diff --git a/resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java b/resilience4j-framework-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java similarity index 94% rename from resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java rename to resilience4j-framework-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java index 75a0cf5993..15bdbf7dad 100644 --- a/resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java +++ b/resilience4j-framework-common/src/test/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventDTOFactoryTest.java @@ -14,7 +14,7 @@ public class BulkheadEventDTOFactoryTest { public void shouldMapBulkheadOnCallFinishedEvent(){ BulkheadOnCallFinishedEvent event = new BulkheadOnCallFinishedEvent("name"); - BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event); + BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event); assertThat(eventDTO.getBulkheadName()).isEqualTo("name"); assertThat(eventDTO.getType()).isEqualTo(CALL_FINISHED); @@ -25,7 +25,7 @@ public void shouldMapBulkheadOnCallFinishedEvent(){ public void shouldMapBulkheadOnCallPermittedEvent(){ BulkheadOnCallPermittedEvent event = new BulkheadOnCallPermittedEvent("name"); - BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event); + BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event); assertThat(eventDTO.getBulkheadName()).isEqualTo("name"); assertThat(eventDTO.getType()).isEqualTo(CALL_PERMITTED); @@ -36,7 +36,7 @@ public void shouldMapBulkheadOnCallPermittedEvent(){ public void shouldMapBulkheadOnCallRejectedEvent(){ BulkheadOnCallRejectedEvent event = new BulkheadOnCallRejectedEvent("name"); - BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTOFactory(event); + BulkheadEventDTO eventDTO = BulkheadEventDTOFactory.createBulkheadEventDTO(event); assertThat(eventDTO.getBulkheadName()).isEqualTo("name"); assertThat(eventDTO.getType()).isEqualTo(CALL_REJECTED); diff --git a/resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactoryTest.java b/resilience4j-framework-common/src/test/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactoryTest.java similarity index 100% rename from resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactoryTest.java rename to resilience4j-framework-common/src/test/java/io/github/resilience4j/circuitbreaker/monitoring/endpoint/CircuitBreakerEventDTOFactoryTest.java diff --git a/resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTOTest.java b/resilience4j-framework-common/src/test/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTOTest.java similarity index 100% rename from resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTOTest.java rename to resilience4j-framework-common/src/test/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventDTOTest.java diff --git a/resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactoryTest.java b/resilience4j-framework-common/src/test/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactoryTest.java similarity index 100% rename from resilience4j-spring-boot-common/src/test/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactoryTest.java rename to resilience4j-framework-common/src/test/java/io/github/resilience4j/retry/monitoring/endpoint/RetryEventDTOFactoryTest.java diff --git a/resilience4j-ratpack/build.gradle b/resilience4j-ratpack/build.gradle index 999b5f882b..2b237b337a 100644 --- a/resilience4j-ratpack/build.gradle +++ b/resilience4j-ratpack/build.gradle @@ -4,6 +4,7 @@ dependencies { implementation ( libraries.groovy ) compileOnly ( libraries.ratpack ) compile project(':resilience4j-annotations') + compile project(':resilience4j-framework-common') compile project(':resilience4j-bulkhead') compile project(':resilience4j-circuitbreaker') compile project(':resilience4j-ratelimiter') diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/Resilience4jModule.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/Resilience4jModule.java index 8c202847bf..3ddc60ae59 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/Resilience4jModule.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/Resilience4jModule.java @@ -45,13 +45,13 @@ import io.github.resilience4j.ratelimiter.annotation.RateLimiter; import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; import io.github.resilience4j.ratpack.bulkhead.BulkheadMethodInterceptor; -import io.github.resilience4j.ratpack.bulkhead.endpoint.BulkheadChain; +import io.github.resilience4j.ratpack.bulkhead.monitoring.endpoint.BulkheadChain; import io.github.resilience4j.ratpack.circuitbreaker.CircuitBreakerMethodInterceptor; -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.CircuitBreakerChain; +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.CircuitBreakerChain; import io.github.resilience4j.ratpack.ratelimiter.RateLimiterMethodInterceptor; -import io.github.resilience4j.ratpack.ratelimiter.endpoint.RateLimiterChain; +import io.github.resilience4j.ratpack.ratelimiter.monitoring.endpoint.RateLimiterChain; import io.github.resilience4j.ratpack.retry.RetryMethodInterceptor; -import io.github.resilience4j.ratpack.retry.endpoint.RetryChain; +import io.github.resilience4j.ratpack.retry.monitoring.endpoint.RetryChain; import io.github.resilience4j.retry.RetryConfig; import io.github.resilience4j.retry.RetryRegistry; import io.github.resilience4j.retry.annotation.Retry; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventDTO.java deleted file mode 100644 index ca1f5839b6..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventDTO.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2017 Jan Sykora - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.bulkhead.endpoint; - -import io.github.resilience4j.bulkhead.event.BulkheadEvent; -import io.github.resilience4j.core.lang.Nullable; - -/** - * DTO to class for publishing bulkhead events. - */ -public class BulkheadEventDTO { - - @Nullable - private String bulkheadName; - @Nullable - private BulkheadEvent.Type type; - @Nullable - private String creationTime; - - BulkheadEventDTO() { - } - - BulkheadEventDTO(String bulkheadName, BulkheadEvent.Type type, String creationTime) { - this.bulkheadName = bulkheadName; - this.type = type; - this.creationTime = creationTime; - } - - public static BulkheadEventDTO createEventDTO(BulkheadEvent bulkheadEvent) { - return new BulkheadEventDTO(bulkheadEvent.getBulkheadName(), bulkheadEvent.getEventType(), bulkheadEvent.getCreationTime().toString()); - } - - @Nullable - public String getBulkheadName() { - return bulkheadName; - } - - public void setBulkheadName(String bulkheadName) { - this.bulkheadName = bulkheadName; - } - - @Nullable - public BulkheadEvent.Type getType() { - return type; - } - - public void setType(BulkheadEvent.Type type) { - this.type = type; - } - - @Nullable - public String getCreationTime() { - return creationTime; - } - - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventsEndpointResponse.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventsEndpointResponse.java deleted file mode 100644 index 9db431a90f..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadEventsEndpointResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2017 Jan Sykora - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.bulkhead.endpoint; - -import io.github.resilience4j.core.lang.Nullable; - -import java.util.List; - -public class BulkheadEventsEndpointResponse { - @Nullable - private List bulkheadEvents; - - public BulkheadEventsEndpointResponse() { - } - - public BulkheadEventsEndpointResponse(List bulkheadEvents) { - this.bulkheadEvents = bulkheadEvents; - } - - @Nullable - public List getBulkheadEvents() { - return bulkheadEvents; - } - - public void setBulkheadEvents(List bulkheadEvents) { - this.bulkheadEvents = bulkheadEvents; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChain.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChain.java similarity index 90% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChain.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChain.java index d2de6ff547..7c937a1a58 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChain.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChain.java @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.resilience4j.ratpack.bulkhead.endpoint; +package io.github.resilience4j.ratpack.bulkhead.monitoring.endpoint; import io.github.resilience4j.bulkhead.Bulkhead; import io.github.resilience4j.bulkhead.BulkheadRegistry; import io.github.resilience4j.bulkhead.event.BulkheadEvent; +import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEventDTOFactory; +import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEventsEndpointResponse; import io.github.resilience4j.consumer.CircularEventConsumer; import io.github.resilience4j.consumer.EventConsumerRegistry; import io.github.resilience4j.ratpack.Resilience4jConfig; @@ -58,13 +60,13 @@ public void execute(Chain chain) throws Exception { .getAllEventConsumer() .flatMap(CircularEventConsumer::getBufferedEvents) .sorted(Comparator.comparing(BulkheadEvent::getCreationTime)) - .map(BulkheadEventDTO::createEventDTO).toJavaList()); + .map(BulkheadEventDTOFactory::createBulkheadEventDTO).toJavaList()); d.success(response); }).then(r -> ctx.render(Jackson.json(r))) ); chain1.get("stream/events", ctx -> { Seq> eventStreams = bulkheadRegistry.getAllBulkheads().map(bulkhead -> ReactorAdapter.toFlux(bulkhead.getEventPublisher())); - Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); + Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTOFactory.createBulkheadEventDTO(b)); ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); @@ -74,7 +76,7 @@ public void execute(Chain chain) throws Exception { BulkheadEventsEndpointResponse response = new BulkheadEventsEndpointResponse(eventConsumerRegistry .getEventConsumer(bulkheadName) .getBufferedEvents() - .map(BulkheadEventDTO::createEventDTO).toJavaList()); + .map(BulkheadEventDTOFactory::createBulkheadEventDTO).toJavaList()); d.success(response); }).then(r -> ctx.render(Jackson.json(r))); } @@ -83,7 +85,7 @@ public void execute(Chain chain) throws Exception { String bulkheadName = ctx.getPathTokens().get("name"); Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); - Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); + Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTOFactory.createBulkheadEventDTO(b)); ServerSentEvents events = ServerSentEvents.serverSentEvents(ReactorAdapter.toFlux(bulkhead.getEventPublisher()), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); @@ -95,7 +97,7 @@ public void execute(Chain chain) throws Exception { .getEventConsumer(bulkheadName) .getBufferedEvents() .filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase())) - .map(BulkheadEventDTO::createEventDTO).toJavaList()); + .map(BulkheadEventDTOFactory::createBulkheadEventDTO).toJavaList()); d.success(response); }).then(r -> ctx.render(Jackson.json(r))); } @@ -107,7 +109,7 @@ public void execute(Chain chain) throws Exception { .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); Flux eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher()) .filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase())); - Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); + Function data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTOFactory.createBulkheadEventDTO(b)); ServerSentEvents events = ServerSentEvents.serverSentEvents(eventStream, e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/package-info.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/package-info.java similarity index 91% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/package-info.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/package-info.java index 994a408912..0d76c1074b 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/package-info.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/package-info.java @@ -18,7 +18,7 @@ */ @NonNullApi @NonNullFields -package io.github.resilience4j.ratpack.retry.endpoint; +package io.github.resilience4j.ratpack.bulkhead.monitoring.endpoint; import io.github.resilience4j.core.lang.NonNullApi; import io.github.resilience4j.core.lang.NonNullFields; \ No newline at end of file diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTO.java deleted file mode 100644 index 8b6bbdd8a5..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; - -import com.fasterxml.jackson.annotation.JsonInclude; -import io.github.resilience4j.circuitbreaker.CircuitBreaker; -import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent; -import io.github.resilience4j.core.lang.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CircuitBreakerEventDTO { - - @Nullable - private String circuitBreakerName; - @Nullable - private CircuitBreakerEvent.Type type; - @Nullable - private String creationTime; - @Nullable - private String errorMessage; - @Nullable - private Long durationInMs; - @Nullable - private CircuitBreaker.StateTransition stateTransition; - - CircuitBreakerEventDTO() { - } - - CircuitBreakerEventDTO(String circuitBreakerName, - CircuitBreakerEvent.Type type, - String creationTime, - @Nullable String errorMessage, - @Nullable Long durationInMs, - @Nullable CircuitBreaker.StateTransition stateTransition) { - this.circuitBreakerName = circuitBreakerName; - this.type = type; - this.creationTime = creationTime; - this.errorMessage = errorMessage; - this.durationInMs = durationInMs; - this.stateTransition = stateTransition; - } - - @Nullable - public String getCircuitBreakerName() { - return circuitBreakerName; - } - - public void setCircuitBreakerName(String circuitBreakerName) { - this.circuitBreakerName = circuitBreakerName; - } - - @Nullable - public CircuitBreakerEvent.Type getType() { - return type; - } - - public void setType(CircuitBreakerEvent.Type type) { - this.type = type; - } - - @Nullable - public String getCreationTime() { - return creationTime; - } - - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } - - @Nullable - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - @Nullable - public Long getDurationInMs() { - return durationInMs; - } - - public void setDurationInMs(Long durationInMs) { - this.durationInMs = durationInMs; - } - - @Nullable - public CircuitBreaker.StateTransition getStateTransition() { - return stateTransition; - } - - public void setStateTransition(CircuitBreaker.StateTransition stateTransition) { - this.stateTransition = stateTransition; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOBuilder.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOBuilder.java deleted file mode 100644 index 523cab2086..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; - -import io.github.resilience4j.circuitbreaker.CircuitBreaker; -import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent; -import io.github.resilience4j.core.lang.Nullable; - -import java.time.Duration; - -class CircuitBreakerEventDTOBuilder { - private String circuitBreakerName; - private CircuitBreakerEvent.Type type; - private String creationTime; - @Nullable - private String throwable = null; - @Nullable - private Long duration = null; - @Nullable - private CircuitBreaker.StateTransition stateTransition = null; - - CircuitBreakerEventDTOBuilder(String circuitBreakerName, CircuitBreakerEvent.Type type, String creationTime){ - this.circuitBreakerName = circuitBreakerName; - this.type = type; - this.creationTime = creationTime; - } - - CircuitBreakerEventDTOBuilder setThrowable(Throwable throwable) { - this.throwable = throwable.toString(); - return this; - } - - CircuitBreakerEventDTOBuilder setDuration(Duration duration) { - this.duration = duration.toMillis(); - return this; - } - - CircuitBreakerEventDTOBuilder setStateTransition(CircuitBreaker.StateTransition stateTransition) { - this.stateTransition = stateTransition; - return this; - } - - CircuitBreakerEventDTO build() { - return new CircuitBreakerEventDTO(circuitBreakerName, type, creationTime, throwable, duration, stateTransition); - } -} \ No newline at end of file diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOFactory.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOFactory.java deleted file mode 100644 index 59abaf8344..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventDTOFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; - -import io.github.resilience4j.circuitbreaker.event.*; - -class CircuitBreakerEventDTOFactory { - - private CircuitBreakerEventDTOFactory(){} - - static CircuitBreakerEventDTO createCircuitBreakerEventDTO(CircuitBreakerEvent event){ - switch(event.getEventType()) { - case ERROR: - CircuitBreakerOnErrorEvent onErrorEvent = (CircuitBreakerOnErrorEvent) event; - return newCircuitBreakerEventDTOBuilder(onErrorEvent).setThrowable(onErrorEvent.getThrowable()).setDuration(onErrorEvent.getElapsedDuration()) - .build(); - case SUCCESS: - CircuitBreakerOnSuccessEvent onSuccessEvent = (CircuitBreakerOnSuccessEvent) event; - return newCircuitBreakerEventDTOBuilder(onSuccessEvent).setDuration(onSuccessEvent.getElapsedDuration()) - .build(); - case RESET: - CircuitBreakerOnResetEvent onResetEvent = (CircuitBreakerOnResetEvent) event; - return newCircuitBreakerEventDTOBuilder(onResetEvent) - .build(); - case STATE_TRANSITION: - CircuitBreakerOnStateTransitionEvent onStateTransitionEvent = (CircuitBreakerOnStateTransitionEvent) event; - return newCircuitBreakerEventDTOBuilder(onStateTransitionEvent).setStateTransition(onStateTransitionEvent.getStateTransition()) - .build(); - case IGNORED_ERROR: - CircuitBreakerOnIgnoredErrorEvent onIgnoredErrorEvent = (CircuitBreakerOnIgnoredErrorEvent) event; - return newCircuitBreakerEventDTOBuilder(onIgnoredErrorEvent).setThrowable(onIgnoredErrorEvent.getThrowable()) - .build(); - case NOT_PERMITTED: - CircuitBreakerOnCallNotPermittedEvent onCallNotPermittedEvent = (CircuitBreakerOnCallNotPermittedEvent) event; - return newCircuitBreakerEventDTOBuilder(onCallNotPermittedEvent) - .build(); - default: - throw new IllegalArgumentException("Invalid event"); - } - } - - private static CircuitBreakerEventDTOBuilder newCircuitBreakerEventDTOBuilder(CircuitBreakerEvent event){ - return new CircuitBreakerEventDTOBuilder(event.getCircuitBreakerName(), event.getEventType(), event.getCreationTime().toString()); - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventsEndpointResponse.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventsEndpointResponse.java deleted file mode 100644 index 9f63536891..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerEventsEndpointResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; - -import io.github.resilience4j.core.lang.Nullable; - -import java.util.List; - -public class CircuitBreakerEventsEndpointResponse { - @Nullable - private List circuitBreakerEvents; - - public CircuitBreakerEventsEndpointResponse(){ - } - - public CircuitBreakerEventsEndpointResponse(List circuitBreakerEvents){ - this.circuitBreakerEvents = circuitBreakerEvents; - } - - @Nullable - public List getCircuitBreakerEvents() { - return circuitBreakerEvents; - } - - public void setCircuitBreakerEvents(List circuitBreakerEvents) { - this.circuitBreakerEvents = circuitBreakerEvents; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChain.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChain.java similarity index 93% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChain.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChain.java index 082c44d9e9..2f5d29c407 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChain.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChain.java @@ -14,17 +14,19 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint; 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.CircuitBreakerEventDTOFactory; +import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpointResponse; import io.github.resilience4j.consumer.CircularEventConsumer; import io.github.resilience4j.consumer.EventConsumerRegistry; import io.github.resilience4j.ratpack.Resilience4jConfig; -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.metrics.CircuitBreakerMetricsDTO; -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.states.CircuitBreakerStateDTO; -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.states.CircuitBreakerStatesEndpointResponse; +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.metrics.CircuitBreakerMetricsDTO; +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.states.CircuitBreakerStateDTO; +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.states.CircuitBreakerStatesEndpointResponse; import io.github.resilience4j.reactor.adapter.ReactorAdapter; import io.vavr.collection.Seq; import ratpack.exec.Promise; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/metrics/CircuitBreakerMetricsDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/metrics/CircuitBreakerMetricsDTO.java similarity index 97% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/metrics/CircuitBreakerMetricsDTO.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/metrics/CircuitBreakerMetricsDTO.java index 898fa1da4b..8d08fe8481 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/metrics/CircuitBreakerMetricsDTO.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/metrics/CircuitBreakerMetricsDTO.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint.metrics; +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.metrics; import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.circuitbreaker.CircuitBreaker; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/package-info.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/package-info.java similarity index 90% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/package-info.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/package-info.java index 4e1f030eaa..7d200a3e5c 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/package-info.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/package-info.java @@ -18,7 +18,7 @@ */ @NonNullApi @NonNullFields -package io.github.resilience4j.ratpack.circuitbreaker.endpoint; +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint; import io.github.resilience4j.core.lang.NonNullApi; import io.github.resilience4j.core.lang.NonNullFields; \ No newline at end of file diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStateDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStateDTO.java similarity index 90% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStateDTO.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStateDTO.java index 0e32478d41..18f230782d 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStateDTO.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStateDTO.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint.states; +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.states; import com.fasterxml.jackson.annotation.JsonInclude; import io.github.resilience4j.circuitbreaker.CircuitBreaker; -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.metrics.CircuitBreakerMetricsDTO; +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.metrics.CircuitBreakerMetricsDTO; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStatesEndpointResponse.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStatesEndpointResponse.java similarity index 93% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStatesEndpointResponse.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStatesEndpointResponse.java index 4218c1d2ca..e489d73daa 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/endpoint/states/CircuitBreakerStatesEndpointResponse.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/states/CircuitBreakerStatesEndpointResponse.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint.states; +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.states; import java.util.List; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventDTO.java deleted file mode 100644 index 8faece29b6..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterEventDTO.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.ratelimiter.endpoint; - -import com.fasterxml.jackson.annotation.JsonInclude; -import io.github.resilience4j.core.lang.Nullable; -import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class RateLimiterEventDTO { - - @Nullable - private String rateLimiterName; - @Nullable - private RateLimiterEvent.Type type; - @Nullable - private String creationTime; - - public static RateLimiterEventDTO createRateLimiterEventDTO(RateLimiterEvent rateLimiterEvent) { - RateLimiterEventDTO dto = new RateLimiterEventDTO(); - dto.setRateLimiterName(rateLimiterEvent.getRateLimiterName()); - dto.setType(rateLimiterEvent.getEventType()); - dto.setCreationTime(rateLimiterEvent.getCreationTime().toString()); - return dto; - } - - @Nullable - public String getRateLimiterName() { - return rateLimiterName; - } - - public void setRateLimiterName(String rateLimiterName) { - this.rateLimiterName = rateLimiterName; - } - - @Nullable - public RateLimiterEvent.Type getType() { - return type; - } - - public void setType(RateLimiterEvent.Type type) { - this.type = type; - } - - @Nullable - public String getCreationTime() { - return creationTime; - } - - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChain.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChain.java similarity index 96% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChain.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChain.java index ff0600bf97..1870228994 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChain.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChain.java @@ -14,13 +14,15 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.ratelimiter.endpoint; +package io.github.resilience4j.ratpack.ratelimiter.monitoring.endpoint; import io.github.resilience4j.consumer.CircularEventConsumer; 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.RateLimiterEventDTO; +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpointResponse; import io.github.resilience4j.ratpack.Resilience4jConfig; import io.github.resilience4j.reactor.adapter.ReactorAdapter; import io.vavr.collection.Seq; diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/package-info.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/package-info.java similarity index 91% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/package-info.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/package-info.java index 0340ae1853..60c7cb0410 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/bulkhead/endpoint/package-info.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/package-info.java @@ -18,7 +18,7 @@ */ @NonNullApi @NonNullFields -package io.github.resilience4j.ratpack.bulkhead.endpoint; +package io.github.resilience4j.ratpack.ratelimiter.monitoring.endpoint; import io.github.resilience4j.core.lang.NonNullApi; import io.github.resilience4j.core.lang.NonNullFields; \ No newline at end of file diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventDTO.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventDTO.java deleted file mode 100644 index 2678f4b1e6..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventDTO.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.retry.endpoint; - -import com.fasterxml.jackson.annotation.JsonInclude; -import io.github.resilience4j.core.lang.Nullable; -import io.github.resilience4j.retry.event.RetryEvent; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class RetryEventDTO { - - @Nullable - private String retryName; - @Nullable - private RetryEvent.Type retryEventType; - private int numberOfRetryAttempts; - @Nullable - private String retryCreationTime; - - public static RetryEventDTO createRetryEventDTO(RetryEvent retryEvent) { - RetryEventDTO dto = new RetryEventDTO(); - dto.setRetryName(retryEvent.getName()); - dto.setRetryEventType(retryEvent.getEventType()); - dto.setNumberOfRetryAttempts(retryEvent.getNumberOfRetryAttempts()); - dto.setRetryCreationTime(retryEvent.getCreationTime().toString()); - return dto; - } - - @Nullable - public String getRetryName() { - return retryName; - } - - public void setRetryName(String retryName) { - this.retryName = retryName; - } - - @Nullable - public RetryEvent.Type getRetryEventType() { - return retryEventType; - } - - public void setRetryEventType(RetryEvent.Type retryEventType) { - this.retryEventType = retryEventType; - } - - public int getNumberOfRetryAttempts() { - return numberOfRetryAttempts; - } - - public void setNumberOfRetryAttempts(int numberOfRetryAttempts) { - this.numberOfRetryAttempts = numberOfRetryAttempts; - } - - @Nullable - public String getRetryCreationTime() { - return retryCreationTime; - } - - public void setRetryCreationTime(String retryCreationTime) { - this.retryCreationTime = retryCreationTime; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventsEndpointResponse.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventsEndpointResponse.java deleted file mode 100644 index 8c9aac060a..0000000000 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryEventsEndpointResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017 Dan Maas - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratpack.retry.endpoint; - -import io.github.resilience4j.core.lang.Nullable; - -import java.util.List; - -public class RetryEventsEndpointResponse { - - @Nullable - private List retryEvents; - - public RetryEventsEndpointResponse() { - } - - public RetryEventsEndpointResponse(List retryEvents) { - this.retryEvents = retryEvents; - } - - @Nullable - public List getRetryEvents() { - return retryEvents; - } - - public void setRetryEvents(List retryEvents) { - this.retryEvents = retryEvents; - } -} diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryChain.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChain.java similarity index 90% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryChain.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChain.java index bf76817c48..5f5310712a 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/endpoint/RetryChain.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChain.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.retry.endpoint; +package io.github.resilience4j.ratpack.retry.monitoring.endpoint; import io.github.resilience4j.consumer.CircularEventConsumer; import io.github.resilience4j.consumer.EventConsumerRegistry; @@ -23,6 +23,9 @@ import io.github.resilience4j.retry.Retry; import io.github.resilience4j.retry.RetryRegistry; import io.github.resilience4j.retry.event.RetryEvent; +import io.github.resilience4j.retry.monitoring.endpoint.RetryEventDTO; +import io.github.resilience4j.retry.monitoring.endpoint.RetryEventDTOFactory; +import io.github.resilience4j.retry.monitoring.endpoint.RetryEventsEndpointResponse; import io.vavr.collection.Seq; import ratpack.exec.Promise; import ratpack.func.Action; @@ -59,13 +62,13 @@ public void execute(Chain chain) throws Exception { List eventsList = eventConsumerRegistry.getAllEventConsumer() .flatMap(CircularEventConsumer::getBufferedEvents) .sorted(Comparator.comparing(RetryEvent::getCreationTime)) - .map(RetryEventDTO::createRetryEventDTO).toJavaList(); + .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList(); d.success(new RetryEventsEndpointResponse(eventsList)); }).then(r -> ctx.render(Jackson.json(r))) ); chain1.get("stream/events", ctx -> { Seq> eventStreams = retryRegistry.getAllRetries().map(retry -> ReactorAdapter.toFlux(retry.getEventPublisher())); - Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTO.createRetryEventDTO(r)); + Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTOFactory.createRetryEventDTO(r)); ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(RetryEvent::getName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); @@ -75,7 +78,7 @@ public void execute(Chain chain) throws Exception { List eventsList = eventConsumerRegistry.getEventConsumer(retryName) .getBufferedEvents() .sorted(Comparator.comparing(RetryEvent::getCreationTime)) - .map(RetryEventDTO::createRetryEventDTO).toJavaList(); + .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList(); d.success(new RetryEventsEndpointResponse(eventsList)); }).then(r -> ctx.render(Jackson.json(r))); } @@ -86,7 +89,7 @@ public void execute(Chain chain) throws Exception { .find(rL -> rL.getName().equals(rateLimiterName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("rate limiter with name %s not found", rateLimiterName))); - Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTO.createRetryEventDTO(r)); + Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTOFactory.createRetryEventDTO(r)); ServerSentEvents events = ServerSentEvents.serverSentEvents(ReactorAdapter.toFlux(retry.getEventPublisher()), e -> e.id(RetryEvent::getName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); @@ -98,7 +101,7 @@ public void execute(Chain chain) throws Exception { .getBufferedEvents() .sorted(Comparator.comparing(RetryEvent::getCreationTime)) .filter(event -> event.getEventType() == RetryEvent.Type.valueOf(eventType.toUpperCase())) - .map(RetryEventDTO::createRetryEventDTO).toJavaList(); + .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList(); d.success(new RetryEventsEndpointResponse(eventsList)); }).then(r -> ctx.render(Jackson.json(r))); } @@ -112,7 +115,7 @@ public void execute(Chain chain) throws Exception { new IllegalArgumentException(String.format("rate limiter with name %s not found", retryName))); Flux eventStream = ReactorAdapter.toFlux(retry.getEventPublisher()) .filter(event -> event.getEventType() == RetryEvent.Type.valueOf(eventType.toUpperCase())); - Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTO.createRetryEventDTO(r)); + Function data = r -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(RetryEventDTOFactory.createRetryEventDTO(r)); ServerSentEvents events = ServerSentEvents.serverSentEvents(eventStream, e -> e.id(RetryEvent::getName).event(c -> c.getEventType().name()).data(data)); ctx.render(events); }); diff --git a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/package-info.java b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/package-info.java similarity index 91% rename from resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/package-info.java rename to resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/package-info.java index 2e05668473..4ac4bdaf03 100644 --- a/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/ratelimiter/endpoint/package-info.java +++ b/resilience4j-ratpack/src/main/java/io/github/resilience4j/ratpack/retry/monitoring/endpoint/package-info.java @@ -18,7 +18,7 @@ */ @NonNullApi @NonNullFields -package io.github.resilience4j.ratpack.ratelimiter.endpoint; +package io.github.resilience4j.ratpack.retry.monitoring.endpoint; import io.github.resilience4j.core.lang.NonNullApi; import io.github.resilience4j.core.lang.NonNullFields; \ No newline at end of file diff --git a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChainSpec.groovy b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChainSpec.groovy similarity index 98% rename from resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChainSpec.groovy rename to resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChainSpec.groovy index 8e78068e2d..c2c79a1af6 100644 --- a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/endpoint/BulkheadChainSpec.groovy +++ b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/bulkhead/monitoring/endpoint/BulkheadChainSpec.groovy @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.resilience4j.ratpack.bulkhead.endpoint +package io.github.resilience4j.ratpack.bulkhead.monitoring.endpoint import com.fasterxml.jackson.databind.ObjectMapper import io.github.resilience4j.bulkhead.BulkheadRegistry +import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEventsEndpointResponse import io.github.resilience4j.ratpack.Resilience4jModule import ratpack.http.client.HttpClient import ratpack.test.embed.EmbeddedApp diff --git a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChainSpec.groovy b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChainSpec.groovy similarity index 97% rename from resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChainSpec.groovy rename to resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChainSpec.groovy index d86882e9f9..8f002cb9b5 100644 --- a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/endpoint/CircuitBreakerChainSpec.groovy +++ b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/circuitbreaker/monitoring/endpoint/CircuitBreakerChainSpec.groovy @@ -14,12 +14,13 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.circuitbreaker.endpoint +package io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint import com.fasterxml.jackson.databind.ObjectMapper import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry +import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpointResponse import io.github.resilience4j.ratpack.Resilience4jModule -import io.github.resilience4j.ratpack.circuitbreaker.endpoint.states.CircuitBreakerStatesEndpointResponse +import io.github.resilience4j.ratpack.circuitbreaker.monitoring.endpoint.states.CircuitBreakerStatesEndpointResponse import ratpack.http.client.HttpClient import ratpack.test.embed.EmbeddedApp import ratpack.test.exec.ExecHarness diff --git a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChainSpec.groovy b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChainSpec.groovy similarity index 98% rename from resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChainSpec.groovy rename to resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChainSpec.groovy index d9ae06afdb..239a22dbe7 100644 --- a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/endpoint/RateLimiterChainSpec.groovy +++ b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/ratelimiter/monitoring/endpoint/RateLimiterChainSpec.groovy @@ -14,11 +14,12 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.ratelimiter.endpoint +package io.github.resilience4j.ratpack.ratelimiter.monitoring.endpoint import com.fasterxml.jackson.databind.ObjectMapper import io.github.resilience4j.ratelimiter.RateLimiterRegistry import io.github.resilience4j.ratelimiter.event.RateLimiterEvent +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpointResponse import io.github.resilience4j.ratpack.Resilience4jModule import ratpack.http.client.HttpClient import ratpack.test.embed.EmbeddedApp diff --git a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/endpoint/RetryChainSpec.groovy b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChainSpec.groovy similarity index 95% rename from resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/endpoint/RetryChainSpec.groovy rename to resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChainSpec.groovy index 251f32d168..d4a6606495 100644 --- a/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/endpoint/RetryChainSpec.groovy +++ b/resilience4j-ratpack/src/test/groovy/io/github/resilience4j/ratpack/retry/monitoring/endpoint/RetryChainSpec.groovy @@ -14,13 +14,14 @@ * limitations under the License. */ -package io.github.resilience4j.ratpack.retry.endpoint +package io.github.resilience4j.ratpack.retry.monitoring.endpoint import com.fasterxml.jackson.databind.ObjectMapper import io.github.resilience4j.ratpack.Resilience4jModule import io.github.resilience4j.retry.Retry import io.github.resilience4j.retry.RetryRegistry import io.github.resilience4j.retry.event.RetryEvent +import io.github.resilience4j.retry.monitoring.endpoint.RetryEventsEndpointResponse import io.vavr.CheckedFunction0 import io.vavr.control.Try import ratpack.http.client.HttpClient @@ -93,7 +94,7 @@ class RetryChainSpec extends Specification { then: "it works" dto.retryEvents.size() == 6 - dto.retryEvents.get(5).retryEventType == RetryEvent.Type.ERROR + dto.retryEvents.get(5).type == RetryEvent.Type.ERROR ['test1', 'test2'].collect { retryRegistry.retry(it).metrics }.each { assert it.numberOfFailedCallsWithoutRetryAttempt == 0 assert it.numberOfFailedCallsWithRetryAttempt == 1 @@ -107,7 +108,7 @@ class RetryChainSpec extends Specification { then: "it works" dto.retryEvents.size() == 3 - dto.retryEvents.get(2).retryEventType == RetryEvent.Type.ERROR + dto.retryEvents.get(2).type == RetryEvent.Type.ERROR when: "we get events for a single retry by type error" actual = client.get('retry/events/test1/error') @@ -115,7 +116,7 @@ class RetryChainSpec extends Specification { then: "it works" dto.retryEvents.size() == 1 - dto.retryEvents.get(0).retryEventType == RetryEvent.Type.ERROR + dto.retryEvents.get(0).type == RetryEvent.Type.ERROR when: "we get events for a single retry by type retry" actual = client.get('retry/events/test1/retry') @@ -123,7 +124,7 @@ class RetryChainSpec extends Specification { then: "it works" dto.retryEvents.size() == 2 - dto.retryEvents.get(0).retryEventType == RetryEvent.Type.RETRY + dto.retryEvents.get(0).type == RetryEvent.Type.RETRY } def "test stream events"() { diff --git a/resilience4j-spring-boot-common/build.gradle b/resilience4j-spring-boot-common/build.gradle index 76ea07590f..7cd2046edf 100644 --- a/resilience4j-spring-boot-common/build.gradle +++ b/resilience4j-spring-boot-common/build.gradle @@ -1,5 +1,6 @@ dependencies { compile project(':resilience4j-spring') + compile project(':resilience4j-framework-common') compileOnly(libraries.spring_boot2_aop) compileOnly(libraries.spring_boot2_config_processor) diff --git a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java b/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java deleted file mode 100644 index f7cebee06a..0000000000 --- a/resilience4j-spring-boot-common/src/main/java/io/github/resilience4j/ratelimiter/monitoring/endpoint/RateLimiterEventsEndpointResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017 Bohdan Storozhuk - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.resilience4j.ratelimiter.monitoring.endpoint; - -import io.github.resilience4j.core.lang.Nullable; - -import java.util.List; - -public class RateLimiterEventsEndpointResponse { - - @Nullable - private List eventsList; - - public RateLimiterEventsEndpointResponse() { - } - - public RateLimiterEventsEndpointResponse(@Nullable List eventsList) { - this.eventsList = eventsList; - } - - @Nullable - public List getEventsList() { - return eventsList; - } - - public void setEventsList(@Nullable List eventsList) { - this.eventsList = eventsList; - } -} diff --git a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java index 737d4237fd..25bd2dbe0c 100644 --- a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java +++ b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java @@ -44,7 +44,7 @@ public BulkheadEventsEndpointResponse getAllBulkheadEvents() { java.util.List response = eventConsumerRegistry.getAllEventConsumer() .flatMap(CircularEventConsumer::getBufferedEvents) .sorted(Comparator.comparing(BulkheadEvent::getCreationTime)) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); @@ -54,7 +54,7 @@ public BulkheadEventsEndpointResponse getAllBulkheadEvents() { @ResponseBody public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadName(@PathVariable("bulkheadName") String bulkheadName) { java.util.List response = getBulkheadEvent(bulkheadName) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); @@ -66,7 +66,7 @@ public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadNameAndEventTyp @PathVariable("eventType") String eventType) { java.util.List response = getBulkheadEvent(bulkheadName) .filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase())) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); diff --git a/resilience4j-spring-boot/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java b/resilience4j-spring-boot/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java index 80d19ab1f4..2e10a587f5 100644 --- a/resilience4j-spring-boot/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java +++ b/resilience4j-spring-boot/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java @@ -104,7 +104,7 @@ public void testRateLimiterAutoConfiguration() throws IOException { ResponseEntity rateLimiterList = restTemplate .getForEntity("/ratelimiter", RateLimiterEndpointResponse.class); - assertThat(rateLimiterList.getBody().getRateLimitersNames()).hasSize(2).containsExactly("backendA", "backendB"); + assertThat(rateLimiterList.getBody().getRateLimiters()).hasSize(2).containsExactly("backendA", "backendB"); try { for (int i = 0; i < 11; i++) { @@ -117,7 +117,7 @@ public void testRateLimiterAutoConfiguration() throws IOException { ResponseEntity rateLimiterEventList = restTemplate .getForEntity("/ratelimiter/events", RateLimiterEventsEndpointResponse.class); - List eventsList = rateLimiterEventList.getBody().getEventsList(); + List eventsList = rateLimiterEventList.getBody().getRateLimiterEvents(); assertThat(eventsList).isNotEmpty(); RateLimiterEventDTO lastEvent = eventsList.get(eventsList.size() - 1); assertThat(lastEvent.getType()).isEqualTo(RateLimiterEvent.Type.FAILED_ACQUIRE); diff --git a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java index e510ec4f73..b1456d9946 100644 --- a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java +++ b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/monitoring/endpoint/BulkheadEventsEndpoint.java @@ -38,7 +38,7 @@ public BulkheadEventsEndpointResponse getAllBulkheadEvents() { java.util.List response = eventConsumerRegistry.getAllEventConsumer() .flatMap(CircularEventConsumer::getBufferedEvents) .sorted(Comparator.comparing(BulkheadEvent::getCreationTime)) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); @@ -47,7 +47,7 @@ public BulkheadEventsEndpointResponse getAllBulkheadEvents() { @ReadOperation public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadName(@Selector String bulkheadName) { java.util.List response = getBulkheadEvent(bulkheadName) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); @@ -57,7 +57,7 @@ public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadName(@Selector public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadNameAndEventType(@Selector String bulkheadName, @Selector String eventType) { java.util.List response = getBulkheadEvent(bulkheadName) .filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase())) - .map(BulkheadEventDTOFactory::createBulkheadEventDTOFactory) + .map(BulkheadEventDTOFactory::createBulkheadEventDTO) .toJavaList(); return new BulkheadEventsEndpointResponse(response); diff --git a/resilience4j-spring-boot2/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java b/resilience4j-spring-boot2/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java index d20098c4f7..4ded6c2612 100644 --- a/resilience4j-spring-boot2/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java +++ b/resilience4j-spring-boot2/src/test/java/io/github/resilience4j/ratelimiter/RateLimiterAutoConfigurationTest.java @@ -94,7 +94,7 @@ public void testRateLimiterAutoConfiguration() throws IOException { ResponseEntity rateLimiterList = restTemplate .getForEntity("/actuator/ratelimiters", RateLimiterEndpointResponse.class); - assertThat(rateLimiterList.getBody().getRateLimitersNames()).hasSize(2).containsExactly("backendA", "backendB"); + assertThat(rateLimiterList.getBody().getRateLimiters()).hasSize(2).containsExactly("backendA", "backendB"); try { for (int i = 0; i < 11; i++) { @@ -107,7 +107,7 @@ public void testRateLimiterAutoConfiguration() throws IOException { ResponseEntity rateLimiterEventList = restTemplate .getForEntity("/actuator/ratelimiterevents", RateLimiterEventsEndpointResponse.class); - List eventsList = rateLimiterEventList.getBody().getEventsList(); + List eventsList = rateLimiterEventList.getBody().getRateLimiterEvents(); assertThat(eventsList).isNotEmpty(); RateLimiterEventDTO lastEvent = eventsList.get(eventsList.size() - 1); assertThat(lastEvent.getType()).isEqualTo(RateLimiterEvent.Type.FAILED_ACQUIRE); diff --git a/settings.gradle b/settings.gradle index 6e6f1120d6..cef68b78ba 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,4 +26,5 @@ include 'resilience4j-reactor' include 'resilience4j-micrometer' include 'resilience4j-bom' include 'resilience4j-spring-boot-common' +include 'resilience4j-framework-common'