Skip to content

Commit

Permalink
eclipse#220 backoff
Browse files Browse the repository at this point in the history
Signed-off-by: Emily Jiang <[email protected]>
  • Loading branch information
Emily-Jiang committed Apr 14, 2020
1 parent c937da6 commit c63150d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
* @see #maxRetries()
* @see #delay()
* @see #delayUnit()
* @see #delayFactor()
* @see #maxDelay()
* @see #maxDelayUnit()
* @see #maxDuration()
* @see #durationUnit()
* @see #jitter()
Expand Down Expand Up @@ -87,6 +90,29 @@
@Nonbinding
ChronoUnit delayUnit() default ChronoUnit.MILLIS;

/**
* The delay factor for {@link #delay}, which exponentially backing off to the maxDelay and multiplying successive delays by the delayFactor. Defaults to 1 if not set.
*
* @return the delay unit
*/
@Nonbinding
double delayFactor() default 1;

/**
* The max delay. Defaults to 60000.
* @return the max delay
*/
@Nonbinding
long maxDelay() default 60000;

/**
* The maxDelay unit for {@link #maxDelay}. Defaults to {@link java.time.temporal.ChronoUnit#MILLIS} if not set.
*
* @return the duration unit
*/
@Nonbinding
ChronoUnit maxDelayUnit() default ChronoUnit.MILLIS;

/**
* The max duration. The max duration must be greater than the delay duration if set. 0 means not set.
*
Expand Down
7 changes: 5 additions & 2 deletions spec/src/main/asciidoc/retry.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ The `Retry` policy allows to configure :
* `maxRetries`: the maximum retries
* `delay`: delays between each retry
* `delayUnit`: the delay unit
* `delayFactor`: the delay factor, which exponentially backs off to the maxDelay and multiplying successive delays by the delayFactor
* `maxDelay`: the maximum delay between the retries
* `maxDelayUnit`: the maximum delay unit
* `maxDuration`: maximum duration to perform the retry for.
* `durationUnit`: duration unit
* `durationUnit`: maximum duration unit
* `jitter`: the random vary of retry delays
* `jitterDelayUnit`: the jitter unit
* `retryOn`: specify the failures to retry on
* `abortOn`: specify the failures to abort on

The delay between the retries will be affected by `delay`, `jitter` and `delayFactor`. After applying the policies, if the delay exceeds the `maxDelay`, the value of `maxDelay` will be used.
=== Retry usage

`@Retry` can be applied to the class or method level.
Expand Down

0 comments on commit c63150d

Please sign in to comment.