Class RetryPolicy.Builder
java.lang.Object
codes.grow.packages.betterstack.core.RetryPolicy.Builder
- Enclosing class:
RetryPolicy
Builder for
RetryPolicy.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Validates and builds the policy.initialBackoff(Duration initialBackoff) Sets the backoff cap of the first retry.maxBackoff(Duration maxBackoff) Sets the upper bound of every backoff.maxRetries(int maxRetries) Sets the maximum number of retries.maxRetryAfter(Duration maxRetryAfter) Sets the longest acceptedRetry-After.multiplier(double multiplier) Sets the exponential growth factor.random(RandomGenerator random) Injects the random source used for jitter (tests).
-
Method Details
-
maxRetries
Sets the maximum number of retries.- Parameters:
maxRetries- retries after the first attempt,>= 0- Returns:
- this builder
-
initialBackoff
Sets the backoff cap of the first retry.- Parameters:
initialBackoff- positive duration- Returns:
- this builder
-
maxBackoff
Sets the upper bound of every backoff.- Parameters:
maxBackoff- positive duration- Returns:
- this builder
-
multiplier
Sets the exponential growth factor.- Parameters:
multiplier- factor>= 1- Returns:
- this builder
-
maxRetryAfter
Sets the longest acceptedRetry-After.- Parameters:
maxRetryAfter- non-negative duration- Returns:
- this builder
-
random
Injects the random source used for jitter (tests).- Parameters:
random- random generator; null restoresThreadLocalRandom- Returns:
- this builder
-
build
Validates and builds the policy.- Returns:
- the policy
- Throws:
ConfigException- when a value is out of range
-