forked from resilience4j/resilience4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue resilience4j#201 bulkhead events corrected
- Loading branch information
Showing
29 changed files
with
404 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...in/java/io/github/resilience4j/bulkhead/adaptive/event/AbstractAdaptiveBulkheadEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* | ||
* Copyright 2019 Mahmoud Romeh | ||
* | ||
* 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 speci`fic language governing permissions and | ||
* limitations under the License. | ||
* | ||
* | ||
*/ | ||
package io.github.resilience4j.bulkhead.adaptive.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNull; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
public abstract class AbstractAdaptiveBulkheadEvent implements AdaptiveBulkheadEvent { | ||
|
||
private final String bulkheadName; | ||
private final ZonedDateTime creationTime; | ||
|
||
AbstractAdaptiveBulkheadEvent(String bulkheadName) { | ||
this.bulkheadName = bulkheadName; | ||
this.creationTime = ZonedDateTime.now(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getBulkheadName() { | ||
return bulkheadName; | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getCreationTime() { | ||
return creationTime; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...d/src/main/java/io/github/resilience4j/bulkhead/adaptive/event/AdaptiveBulkheadEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package io.github.resilience4j.bulkhead.adaptive.event; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
/** | ||
* adaptive bulkhead event | ||
*/ | ||
public interface AdaptiveBulkheadEvent { | ||
/** | ||
* Returns the name of the bulkhead which has created the event. | ||
* | ||
* @return the name of the bulkhead which has created the event | ||
*/ | ||
String getBulkheadName(); | ||
|
||
/** | ||
* Returns the type of the bulkhead event. | ||
* | ||
* @return the type of the bulkhead event | ||
*/ | ||
Type getEventType(); | ||
|
||
|
||
/** | ||
* Returns the creation time of adaptive bulkhead event. | ||
* | ||
* @return the creation time of adaptive bulkhead event | ||
*/ | ||
ZonedDateTime getCreationTime(); | ||
|
||
|
||
/** | ||
* Event types which are created by a bulkhead. | ||
*/ | ||
enum Type { | ||
/** | ||
* A AdaptiveBulkheadEvent which informs that a limit has been increased | ||
*/ | ||
LIMIT_INCREASED(false), | ||
/** | ||
* A AdaptiveBulkheadEvent which informs that a limit has been decreased | ||
*/ | ||
LIMIT_DECREASED(false), | ||
/** | ||
* An adaptive bulkhead event which informs that an error has been recorded | ||
*/ | ||
ERROR(false), | ||
/** | ||
* An adaptive bulkhead which informs that an error has been ignored | ||
*/ | ||
IGNORED_ERROR(false), | ||
/** | ||
* An adaptive bulkhead which informs that a success has been recorded | ||
*/ | ||
SUCCESS(false), | ||
|
||
/** | ||
* A AdaptiveBulkheadEvent which informs the state of the AdaptiveBulkhead has been changed | ||
*/ | ||
STATE_TRANSITION(true), | ||
/** | ||
* A AdaptiveBulkheadEvent which informs the AdaptiveBulkhead has been reset | ||
*/ | ||
RESET(true), | ||
/** | ||
* A AdaptiveBulkheadEvent which informs the AdaptiveBulkhead has been disabled | ||
*/ | ||
DISABLED(false); | ||
|
||
public final boolean forcePublish; | ||
|
||
Type(boolean forcePublish) { | ||
this.forcePublish = forcePublish; | ||
} | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...ad/src/main/java/io/github/resilience4j/bulkhead/adaptive/event/BulkheadOnErrorEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* Copyright 2019 Mahmoud Romeh | ||
* | ||
* 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.bulkhead.adaptive.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNull; | ||
|
||
/** | ||
* A BulkheadEvent which informs that a call has been failed | ||
*/ | ||
public class BulkheadOnErrorEvent extends AbstractAdaptiveBulkheadEvent { | ||
|
||
private final String exceptionMsg; | ||
|
||
public BulkheadOnErrorEvent(String bulkheadName, Throwable throwable) { | ||
super(bulkheadName); | ||
this.exceptionMsg = throwable.getMessage(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Type getEventType() { | ||
return Type.ERROR; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: Bulkhead '%s' recorded an error: '%s'", | ||
getCreationTime(), | ||
getBulkheadName(), | ||
exceptionMsg | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...d/src/main/java/io/github/resilience4j/bulkhead/adaptive/event/BulkheadOnIgnoreEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* Copyright 2019 Mahmoud Romeh | ||
* | ||
* 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.bulkhead.adaptive.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNull; | ||
|
||
/** | ||
* A BulkheadEvent which informs that an error has been ignored | ||
*/ | ||
public class BulkheadOnIgnoreEvent extends AbstractAdaptiveBulkheadEvent { | ||
|
||
private final String exceptionMsg; | ||
|
||
public BulkheadOnIgnoreEvent(String bulkheadName, Throwable throwable) { | ||
super(bulkheadName); | ||
this.exceptionMsg = throwable.getMessage(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Type getEventType() { | ||
return Type.IGNORED_ERROR; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: Bulkhead '%s' recorded an error which has been ignored: '%s'.", | ||
getCreationTime(), | ||
getBulkheadName(), | ||
exceptionMsg | ||
); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...in/java/io/github/resilience4j/bulkhead/adaptive/event/BulkheadOnLimitDecreasedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* | ||
* Copyright 2019 Mahmoud Romeh | ||
* | ||
* 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.bulkhead.adaptive.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNull; | ||
|
||
/** | ||
* A BulkheadEvent which informs that a limit has been decreased | ||
*/ | ||
public class BulkheadOnLimitDecreasedEvent extends AbstractAdaptiveBulkheadEvent { | ||
|
||
private final int newMaxConcurrentCalls; | ||
|
||
public BulkheadOnLimitDecreasedEvent(String bulkheadName, int newMaxConcurrentCalls) { | ||
super(bulkheadName); | ||
this.newMaxConcurrentCalls = newMaxConcurrentCalls; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Type getEventType() { | ||
return Type.LIMIT_DECREASED; | ||
} | ||
|
||
public int getNewMaxConcurrentCalls() { | ||
return newMaxConcurrentCalls; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: Bulkhead '%s' recorded a limit decrease: %s", | ||
getCreationTime(), | ||
getBulkheadName(), | ||
newMaxConcurrentCalls | ||
); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...in/java/io/github/resilience4j/bulkhead/adaptive/event/BulkheadOnLimitIncreasedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* | ||
* Copyright 2019 Mahmoud Romeh | ||
* | ||
* 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.bulkhead.adaptive.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNull; | ||
|
||
/** | ||
* A BulkheadEvent which informs that a limit has been increased | ||
*/ | ||
public class BulkheadOnLimitIncreasedEvent extends AbstractAdaptiveBulkheadEvent { | ||
|
||
private final int newMaxConcurrentCalls; | ||
|
||
public BulkheadOnLimitIncreasedEvent(String bulkheadName, int newMaxConcurrentCalls) { | ||
super(bulkheadName); | ||
this.newMaxConcurrentCalls = newMaxConcurrentCalls; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Type getEventType() { | ||
return Type.LIMIT_INCREASED; | ||
} | ||
|
||
public int getNewMaxConcurrentCalls() { | ||
return newMaxConcurrentCalls; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: Bulkhead '%s' recorded a limit increase: %s", | ||
getCreationTime(), | ||
getBulkheadName(), | ||
newMaxConcurrentCalls | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.