bumped exponential backoff in Retryer.Default and made it possible to adjust by codefromthecrypt · Pull Request #5 · OpenFeign/feign · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
22 changes: 15 additions & 7 deletions feign-core/src/main/java/feign/Retryer.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,27 @@ public interface Retryer {
void continueOrPropagate(RetryableException e);

public static class Default implements Retryer {
private final int maxAttempts = 5;
private final long period = MILLISECONDS.toNanos(50);
private final long maxPeriod = SECONDS.toNanos(1);

// visible for testing;
Ticker ticker = Ticker.systemTicker();
int attempt;
long sleptForNanos;
private final int maxAttempts;
private final long period;
private final long maxPeriod;

public Default() {
this(MILLISECONDS.toNanos(100), SECONDS.toNanos(1), 5);
}

public Default(long period, long maxPeriod, int maxAttempts) {
this.period = period;
this.maxPeriod = maxPeriod;
this.maxAttempts = maxAttempts;
this.attempt = 1;
}

// visible for testing;
Ticker ticker = Ticker.systemTicker();
int attempt;
long sleptForNanos;

public void continueOrPropagate(RetryableException e) {
if (attempt++ >= maxAttempts)
throw e;
Expand Down
8 changes: 4 additions & 4 deletions feign-core/src/test/java/feign/DefaultRetryerTest.java