public interface OciCircuitBreaker
Modifier and Type | Interface and Description |
---|---|
static interface |
OciCircuitBreaker.Config |
static class |
OciCircuitBreaker.ErrorHistoryItem |
Modifier and Type | Method and Description |
---|---|
void |
acquirePermission()
Try to obtain a permission to execute a call.
|
void |
addToHistory(Throwable throwable,
Integer status,
Map<String,String> messages) |
String |
circuitBreakerCallNotPermittedErrorMessage(String requestUri) |
CallNotAllowedException |
createCallNotAllowedException() |
OciCircuitBreaker.Config |
getCircuitBreakerConfig()
Returns the CircuitBreakerConfig of this CircuitBreaker.
|
long |
getCurrentTimestamp()
Returns the current time with respect to the CircuitBreaker currentTimeFunction.
|
List<OciCircuitBreaker.ErrorHistoryItem> |
getHistory() |
String |
getHistoryAsString() |
String |
getName()
Returns the name of this CircuitBreaker.
|
io.github.resilience4j.circuitbreaker.CircuitBreaker |
getR4jCircuitBreaker() |
io.github.resilience4j.circuitbreaker.CircuitBreaker.State |
getState()
Returns the state of this CircuitBreaker.
|
TimeUnit |
getTimestampUnit()
Returns the timeUnit of current timestamp.
|
void |
onError(long duration,
TimeUnit durationUnit,
Throwable throwable)
Records a failed call.
|
void |
onResult(long duration,
TimeUnit durationUnit,
Object result)
This method must be invoked when a call returned a result and the result predicate should
decide if the call was successful or not.
|
void |
onSuccess(long duration,
TimeUnit durationUnit)
Records a successful call.
|
void |
releasePermission()
Releases a permission.
|
boolean |
tryAcquirePermission()
Acquires a permission to execute a call, only if one is available at the time of invocation.
|
io.github.resilience4j.circuitbreaker.CircuitBreaker getR4jCircuitBreaker()
String getName()
Returns the name of this CircuitBreaker.
io.github.resilience4j.circuitbreaker.CircuitBreaker.State getState()
Returns the state of this CircuitBreaker.
boolean tryAcquirePermission()
Acquires a permission to execute a call, only if one is available at the time of invocation. If a call is not permitted, the number of not permitted calls is increased.
Returns false when the state is OPEN or FORCED_OPEN. Returns true when the state is CLOSED or DISABLED. Returns true when the state is HALF_OPEN and further test calls are allowed. Returns false when the state is HALF_OPEN and the number of test calls has been reached. If the state is HALF_OPEN, the number of allowed test calls is decreased. Important: Make sure to call onSuccess or onError after the call is finished. If the call is cancelled before it is invoked, you have to release the permission again.
true
if a permission was acquired and false
otherwisevoid releasePermission()
Releases a permission.
Should only be used when a permission was acquired but not used. Otherwise use CircuitBreaker.onSuccess(long, TimeUnit)
or CircuitBreaker.onError(long, TimeUnit,
Throwable)
to signal a completed or failed call.
If the state is HALF_OPEN, the number of allowed test calls is increased by one.
void acquirePermission()
Try to obtain a permission to execute a call. If a call is not permitted, the number of not permitted calls is increased.
Throws a CallNotPermittedException when the state is OPEN or FORCED_OPEN. Returns when the state is CLOSED or DISABLED. Returns when the state is HALF_OPEN and further test calls are allowed. Throws a CallNotPermittedException when the state is HALF_OPEN and the number of test calls has been reached. If the state is HALF_OPEN, the number of allowed test calls is decreased. Important: Make sure to call onSuccess or onError after the call is finished. If the call is cancelled before it is invoked, you have to release the permission again.
io.github.resilience4j.circuitbreaker.CallNotPermittedException
- when CircuitBreaker is OPEN or HALF_OPEN and no further
test calls are permitted.long getCurrentTimestamp()
Returns the current time with respect to the CircuitBreaker currentTimeFunction. Returns System.nanoTime() by default.
TimeUnit getTimestampUnit()
Returns the timeUnit of current timestamp. Default is TimeUnit.NANOSECONDS.
void onError(long duration, TimeUnit durationUnit, Throwable throwable)
Records a failed call. This method must be invoked when a call failed.
duration
- The elapsed time duration of the calldurationUnit
- The duration unitthrowable
- The throwable which must be recordedvoid onSuccess(long duration, TimeUnit durationUnit)
Records a successful call. This method must be invoked when a call was successful.
duration
- The elapsed time duration of the calldurationUnit
- The duration unitvoid onResult(long duration, TimeUnit durationUnit, Object result)
This method must be invoked when a call returned a result and the result predicate should decide if the call was successful or not.
duration
- The elapsed time duration of the calldurationUnit
- The duration unitresult
- The result of the protected functionOciCircuitBreaker.Config getCircuitBreakerConfig()
Returns the CircuitBreakerConfig of this CircuitBreaker.
CallNotAllowedException createCallNotAllowedException()
String circuitBreakerCallNotPermittedErrorMessage(String requestUri)
List<OciCircuitBreaker.ErrorHistoryItem> getHistory()
String getHistoryAsString()
Copyright © 2016–2024. All rights reserved.