Interface OciCircuitBreaker


  • public interface OciCircuitBreaker
    • Method Detail

      • getR4jCircuitBreaker

        io.github.resilience4j.circuitbreaker.CircuitBreaker getR4jCircuitBreaker()
      • getName

        String getName()
        Returns the name of this CircuitBreaker.
        Returns:
        the name of this CircuitBreaker
      • getState

        io.github.resilience4j.circuitbreaker.CircuitBreaker.State getState()
        Returns the state of this CircuitBreaker.
        Returns:
        the state of this CircuitBreaker
      • tryAcquirePermission

        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.

        Returns:
        true if a permission was acquired and false otherwise
      • releasePermission

        void 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.

      • acquirePermission

        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.

        Throws:
        io.github.resilience4j.circuitbreaker.CallNotPermittedException - when CircuitBreaker is OPEN or HALF_OPEN and no further test calls are permitted.
      • getCurrentTimestamp

        long getCurrentTimestamp()
        Returns the current time with respect to the CircuitBreaker currentTimeFunction.

        Returns System.nanoTime() by default.

        Returns:
        current timestamp
      • getTimestampUnit

        TimeUnit getTimestampUnit()
        Returns the timeUnit of current timestamp.

        Default is TimeUnit.NANOSECONDS.

        Returns:
        the timeUnit of current timestamp
      • onError

        void onError​(long duration,
                     TimeUnit durationUnit,
                     Throwable throwable)
        Records a failed call.

        This method must be invoked when a call failed.

        Parameters:
        duration - The elapsed time duration of the call
        durationUnit - The duration unit
        throwable - The throwable which must be recorded
      • onSuccess

        void onSuccess​(long duration,
                       TimeUnit durationUnit)
        Records a successful call.

        This method must be invoked when a call was successful.

        Parameters:
        duration - The elapsed time duration of the call
        durationUnit - The duration unit
      • onResult

        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.
        Parameters:
        duration - The elapsed time duration of the call
        durationUnit - The duration unit
        result - The result of the protected function
      • getCircuitBreakerConfig

        OciCircuitBreaker.Config getCircuitBreakerConfig()
        Returns the CircuitBreakerConfig of this CircuitBreaker.
        Returns:
        the CircuitBreakerConfig of this CircuitBreaker
      • circuitBreakerCallNotPermittedErrorMessage

        String circuitBreakerCallNotPermittedErrorMessage​(String requestUri)
      • getHistoryAsString

        String getHistoryAsString()