Setting the defaults for the BackoffPolicy in the builder constructor
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
This commit is contained in:
parent
30c0ddb5e2
commit
b0bac0c29a
|
|
@ -13,7 +13,7 @@ public class BackoffPolicy {
|
||||||
/**
|
/**
|
||||||
* Retry indefinitely, default behavior
|
* Retry indefinitely, default behavior
|
||||||
*/
|
*/
|
||||||
public static final int UNLIMITED_RETRIES = -1;
|
public static final int UNLIMITED_RETRIES = 0;
|
||||||
|
|
||||||
private static final int BACKOFF_MULTIPLIER = 2;
|
private static final int BACKOFF_MULTIPLIER = 2;
|
||||||
|
|
||||||
|
|
@ -45,10 +45,10 @@ public class BackoffPolicy {
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
public BackoffPolicy(Duration initialDelay, Duration maxDelay, int maxRetries, UnaryOperator<Duration> backoffFunction) {
|
public BackoffPolicy(Duration initialDelay, Duration maxDelay, int maxRetries, UnaryOperator<Duration> backoffFunction) {
|
||||||
this.initialDelay = initialDelay;
|
this.initialDelay = initialDelay != null ? initialDelay : Duration.ofSeconds(1);
|
||||||
this.maxDelay = maxDelay;
|
this.maxDelay = maxDelay != null ? maxDelay : Duration.ofSeconds(60);
|
||||||
this.maxRetries = maxRetries;
|
this.maxRetries = maxRetries;
|
||||||
this.backoffFunction = backoffFunction;
|
this.backoffFunction = backoffFunction != null ? backoffFunction : d -> d.multipliedBy(BACKOFF_MULTIPLIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue