-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add exponential backoff to api core (#102)
* First set of changes * Use retry mechanism on all requests * More constructors, some docs comments * Actually leverage OOP 🤦 * Further implement options config * Backoff options fix + tests * Improved logic, APICore tests * Better docs strings, linting * Replace custom logic with Resilience4j Retry * Move to older version of resilience4j * Add samples, undo Source constructor changes * Linting
- Loading branch information
Showing
13 changed files
with
298 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.coveo.pushapiclient; | ||
|
||
public class BackoffOptions { | ||
private final int retryAfter; | ||
private final int maxRetries; | ||
private final int timeMultiple; | ||
|
||
public BackoffOptions(int retryAfter, int maxRetries, int timeMultiple) { | ||
this.retryAfter = retryAfter; | ||
this.maxRetries = maxRetries; | ||
this.timeMultiple = timeMultiple; | ||
} | ||
|
||
public int getRetryAfter() { | ||
return this.retryAfter; | ||
} | ||
|
||
public int getMaxRetries() { | ||
return this.maxRetries; | ||
} | ||
|
||
public int getTimeMultiple() { | ||
return this.timeMultiple; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/coveo/pushapiclient/BackoffOptionsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.coveo.pushapiclient; | ||
|
||
public class BackoffOptionsBuilder { | ||
public static final int DEFAULT_RETRY_AFTER = 5000; | ||
public static final int DEFAULT_MAX_RETRIES = 50; | ||
public static final int DEFAULT_TIME_MULTIPLE = 2; | ||
|
||
private int retryAfter = DEFAULT_RETRY_AFTER; | ||
private int maxRetries = DEFAULT_MAX_RETRIES; | ||
private int timeMultiple = DEFAULT_TIME_MULTIPLE; | ||
|
||
public BackoffOptionsBuilder withRetryAfter(int retryAfter) { | ||
this.retryAfter = retryAfter; | ||
return this; | ||
} | ||
|
||
public BackoffOptionsBuilder withMaxRetries(int maxRetries) { | ||
this.maxRetries = maxRetries; | ||
return this; | ||
} | ||
|
||
public BackoffOptionsBuilder withTimeMultiple(int timeMultiple) { | ||
this.timeMultiple = timeMultiple; | ||
return this; | ||
} | ||
|
||
public BackoffOptions build() { | ||
return new BackoffOptions(this.retryAfter, this.maxRetries, this.timeMultiple); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.