Class RetryPolicy
- 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 anExtractionPluginClientfor 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 usingbackOffMultiplier(double), up tomaxBackOff(Duration).
-
-
Constructor Summary
Constructors Constructor Description RetryPolicy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryPolicybackOffMultiplier(double backOffMultiplier)The factor to multiply the maximum backoff value with on each iteration.RetryPolicyinitialBackoffMs(Duration initialBackoff)The initial wait time bound of the first retry iteration.RetryPolicymaxAttempts(int maxAttempts)Set the maximum total attempts trying to connect.RetryPolicymaxBackOff(Duration maxBackOff)The maximum wait time bound for any iteration.static RetryPolicywithDefaultSettings()Get a default policy, which has the following parameters:maxAttempts=10, initialBackoff=250ms, maxBackOff=10s, backOffMultiplier=2.
-
-
-
Method Detail
-
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 themaximum 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 theinitial 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
-
-