feat: Add retry with predicate (#1269)
This commit is contained in:
parent
64e07dcf1b
commit
77532c1bb5
4 changed files with 500 additions and 37 deletions
|
|
@ -85,4 +85,17 @@ public class FutureDocTest extends AbstractJavaTest {
|
|||
|
||||
retriedFuture.toCompletableFuture().get(2, SECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useRetryWithPredicate() throws Exception {
|
||||
// #retry
|
||||
Callable<CompletionStage<String>> attempt = () -> CompletableFuture.completedFuture("test");
|
||||
|
||||
CompletionStage<String> retriedFuture =
|
||||
Patterns.retry(
|
||||
attempt, (notUsed, e) -> e != null, 3, java.time.Duration.ofMillis(200), system);
|
||||
// #retry
|
||||
|
||||
retriedFuture.toCompletableFuture().get(2, SECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue