java.lang.Object
org.hansken.plugin.extraction.runtime.grpc.client.RetryPolicy

public final class RetryPolicy extends Object
A configurable exponential backoff policy which can be used by an ExtractionPluginClient for trying to connect when requesting the plugin information or processing a Trace, instead of failing directly due to unavailability.

The retry algorithm will at each iteration wait between 0 and the current iteration backoff time. The backoff starts with the initialBackoffMs(Duration), and is multiplied each iteration using backOffMultiplier(double), up to maxBackOff(Duration).

  • Constructor Details

    • RetryPolicy

      public RetryPolicy()
  • Method Details

    • withDefaultSettings

      public static RetryPolicy withDefaultSettings()
      Get a default policy, which has the following parameters: maxAttempts=10, initialBackoff=250ms, maxBackOff=10s, backOffMultiplier=2 .
      Returns:
      a retry policy with default settings
    • maxAttempts

      public RetryPolicy maxAttempts(int maxAttempts)
      Set the maximum total attempts trying to connect. The value should be at least 2.
      Parameters:
      maxAttempts - the maximum number of attempts
      Returns:
      this
    • initialBackoffMs

      public RetryPolicy initialBackoffMs(Duration initialBackoff)
      The initial wait time bound of the first retry iteration. Must be less than or equal to the maximum backoff.
      Parameters:
      initialBackoff - the initial backoff value
      Returns:
      this
    • maxBackOff

      public RetryPolicy maxBackOff(Duration maxBackOff)
      The maximum wait time bound for any iteration. Must be greater than or equal to the initial backoff.
      Parameters:
      maxBackOff - the maximum backoff value
      Returns:
      this
    • backOffMultiplier

      public RetryPolicy backOffMultiplier(double backOffMultiplier)
      The factor to multiply the maximum backoff value with on each iteration. Should be greater than or equal to 1.
      Parameters:
      backOffMultiplier - the backoff scale factor
      Returns:
      this