forked from resilience4j/resilience4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue resilience4j#1043: Added IntervalBiFunction to RetryConfig to c…
…alculate wait duration based on result/exception (resilience4j#1200)
- Loading branch information
1 parent
2dd4adb
commit 7952a61
Showing
8 changed files
with
222 additions
and
26 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
resilience4j-core/src/main/java/io/github/resilience4j/core/IntervalBiFunction.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,18 @@ | ||
package io.github.resilience4j.core; | ||
|
||
import io.vavr.control.Either; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* An IntervalBiFunction which can be used to calculate the wait interval. The input parameters of the bi | ||
* function is the number of attempts (attempt) and either result or exception, the output parameter is the wait interval in | ||
* milliseconds. The attempt parameter starts at 1 and increases with every further attempt. | ||
*/ | ||
@FunctionalInterface | ||
public interface IntervalBiFunction<T> extends BiFunction<Integer, Either<Throwable, T>, Long> { | ||
|
||
static <T> IntervalBiFunction<T> ofIntervalFunction(IntervalFunction f) { | ||
return (attempt, either) -> f.apply(attempt); | ||
} | ||
} |
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.