Class RetryableScope

java.lang.Object
io.bdeploy.common.RetryableScope

public class RetryableScope extends Object
  • Method Details

    • create

      public static RetryableScope create()
    • withExceptionHandler

      public RetryableScope withExceptionHandler(Consumer<Exception> e)
      Replaces the default exception handler (including delay handling of retries) with a custom one.
    • withDelay

      public RetryableScope withDelay(long ms)
      Sets the timeout the default exception handler will delay retries in milliseconds. The default is 100ms.
    • withMaxRetries

      public RetryableScope withMaxRetries(long amount)
      Sets the amount of retries that the action will be re-called in case of an exception. The default is 10.
    • run

      public void run(Runnable action)
      Perform the given action. Retry execution up to withMaxRetries(long) trimes, with a delay of withDelay(long) milliseconds between retries (given the exception and timeout handler has not been replaced using withExceptionHandler(Consumer)).