Removes use of DefaultRepeat, moves iteration count to predicate.

This commit is contained in:
Spencer Gibb
2018-02-15 14:16:38 -05:00
parent 3bc54ab82c
commit 9ba1e67fd6

View File

@@ -67,6 +67,12 @@ public class RetryGatewayFilterFactory implements GatewayFilterFactory {
retry.validate();
Predicate<? super RepeatContext<ServerWebExchange>> predicate = context -> {
boolean retryableAttempt = context.iteration() < retry.getRetries();
if (!retryableAttempt) {
return false;
}
ServerWebExchange exchange = context.applicationContext();
HttpStatus statusCode = exchange.getResponse().getStatusCode();
HttpMethod httpMethod = exchange.getRequest().getMethod();
@@ -84,7 +90,7 @@ public class RetryGatewayFilterFactory implements GatewayFilterFactory {
};
//TODO: use Repeat statics once updated with a create() like method
Repeat<ServerWebExchange> repeat = DefaultRepeat.create(predicate, retry.getRetries());
Repeat<ServerWebExchange> repeat = Repeat.onlyIf(predicate);
//TODO: support timeout, backoff, jitter, etc... in Builder
return apply(repeat);