Add MVC retry backoff support#4225
Open
goutamadwant wants to merge 1 commit into
Open
Conversation
Fixes spring-cloudgh-4141 Signed-off-by: Goutam Adwant <workwithgoutam@gmail.com>
Contributor
|
@spencergibb I wonder if we should just move to using Framework retry. However just glancing at the code it looks like it might involve breaking changes due to some interfaces we implement. |
Member
|
I think spring-retry is around until the next major |
ryanjbaxter
requested changes
Jun 26, 2026
| * `backoff`: The configured exponential backoff for the retries. | ||
| Retries are performed after a backoff interval of `firstBackoff * (factor ^ n)`, where `n` is the iteration. | ||
| If `maxBackoff` is configured, the maximum backoff applied is limited to `maxBackoff`. | ||
| If `basedOnPreviousValue` is true, the backoff is calculated by using `prevBackoff * factor`. |
Contributor
There was a problem hiding this comment.
basedOnPreviousValue does not appear to be used in the MVC implementation...I am not sure it makes sense fir MVC
| } | ||
|
|
||
| public void validate() { | ||
| Objects.requireNonNull(this.firstBackoff, "firstBackoff must be present"); |
Contributor
There was a problem hiding this comment.
It probably makes sense to do some additional validation here
Objects.requireNonNull(this.firstBackoff, "firstBackoff must be present");
Assert.isTrue(this.firstBackoff.toMillis() >= 1, "firstBackoff must be >= 1ms");
Assert.isTrue(this.factor > 1, "factor must be greater than 1");
if (this.maxBackoff != null) {
Assert.isTrue(this.maxBackoff.compareTo(this.firstBackoff) > 0,
"maxBackoff must be greater than firstBackoff");
}
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
backoffsupport to MVCRetryConfigwithfirstBackoff,maxBackoff,factor, andbasedOnPreviousValueGatewayRetryFilterFunctionsandFrameworkRetryFilterFunctionsFixes #4141
Testing
./mvnw -pl spring-cloud-gateway-server-webmvc -Dtest=RetryFilterFunctionBackoffTests,RetryFilterFunctionSelectionLogicTests,RetryFilterFunctionNoSpringRetrySelectionTests test./mvnw -pl spring-cloud-gateway-server-webmvc -DskipTests verify