Skip to content

Commit

Permalink
Created a resilience4j-framework-common module which hosts common cod… (
Browse files Browse the repository at this point in the history
ReactiveX#455)

* Created a resilience4j-framework-common module which hosts common code which is shared between Spring Boot 1, Spring Boot 2, Ratpack and in future Micronaut.
  • Loading branch information
RobWin authored May 19, 2019
1 parent de3bfbe commit 8dfd276
Show file tree
Hide file tree
Showing 61 changed files with 102 additions and 687 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ List of available endpoints:
Example of response:
----
{
"eventsList": [
"rateLimiterEvents": [
{
"rateLimiterName": "backendA",
"type": "SUCCESSFUL_ACQUIRE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ List of available endpoints:
Example of response:
----
{
"eventsList": [
"rateLimiterEvents": [
{
"rateLimiterName": "backendA",
"type": "SUCCESSFUL_ACQUIRE",
Expand Down
9 changes: 9 additions & 0 deletions resilience4j-framework-common/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
public class RateLimiterEndpointResponse {

@Nullable
private List<String> rateLimitersNames;
private List<String> rateLimiters;

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

public RateLimiterEndpointResponse(@Nullable List<String> rateLimitersNames) {
this.rateLimitersNames = rateLimitersNames;
public RateLimiterEndpointResponse(@Nullable List<String> rateLimiters) {
this.rateLimiters = rateLimiters;
}

@Nullable
public List<String> getRateLimitersNames() {
return rateLimitersNames;
public List<String> getRateLimiters() {
return rateLimiters;
}

public void setRateLimitersNames(@Nullable List<String> rateLimitersNames) {
this.rateLimitersNames = rateLimitersNames;
public void setRateLimiters(@Nullable List<String> rateLimiters) {
this.rateLimiters = rateLimiters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;

Expand All @@ -27,7 +27,7 @@ public class RateLimiterEventsEndpointResponse {
public RateLimiterEventsEndpointResponse() {
}

public RateLimiterEventsEndpointResponse(List<RateLimiterEventDTO> rateLimiterEvents) {
public RateLimiterEventsEndpointResponse(@Nullable List<RateLimiterEventDTO> rateLimiterEvents) {
this.rateLimiterEvents = rateLimiterEvents;
}

Expand All @@ -36,7 +36,7 @@ public List<RateLimiterEventDTO> getRateLimiterEvents() {
return rateLimiterEvents;
}

public void setRateLimiterEvents(List<RateLimiterEventDTO> rateLimiterEvents) {
public void setRateLimiterEvents(@Nullable List<RateLimiterEventDTO> rateLimiterEvents) {
this.rateLimiterEvents = rateLimiterEvents;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RetryEventDTO> retryEvents;

public RetryEventsEndpointResponse() {
Expand All @@ -30,6 +34,7 @@ public RetryEventsEndpointResponse(List<RetryEventDTO> retryEvents) {
this.retryEvents = retryEvents;
}

@Nullable
public List<RetryEventDTO> getRetryEvents() {
return retryEvents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions resilience4j-ratpack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8dfd276

Please sign in to comment.