eclipse-vertx / eclipse-vertx/vert.x
Retry on Future
- Dominant language
- Java
- Stars
- 14.7k
- Forks
- 2.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 28
Description
Introduce configurable retry mechanism on Future interface.
There are many use causes where this feature would be useful and would shorten a lot of boilerplate code that is copied and reused on many places in user code. Example is, retry of WebClient HTTP request that fails for recoverable reasons.
This is already available on rx api via multiple functions:
1. [retry](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retry--)()
Repeatedly re-subscribes to the current Single indefinitely if it fails with an onError.
2. [retry](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retry-io.reactivex.rxjava3.functions.BiPredicate-)([@NonNull](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/annotations/NonNull.html) [BiPredicate](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/BiPredicate.html) predicate)
Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError.
3. [retry](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retry-long-)(long times)
Repeatedly re-subscribe at most the specified times to the current Single if it fails with an onError.
4. [retry](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retry-long-io.reactivex.rxjava3.functions.Predicate-)(long times, [@NonNull](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/annotations/NonNull.html) [Predicate](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/Predicate.html) predicate)
Repeatedly re-subscribe at most times or until the predicate returns false, whichever happens first if it fails with an onError.
5. [retry](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retry-io.reactivex.rxjava3.functions.Predicate-)([@NonNull](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/annotations/NonNull.html) [Predicate](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/Predicate.html) predicate)
Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError.
6. [retryUntil](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retryUntil-io.reactivex.rxjava3.functions.BooleanSupplier-)([@NonNull](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/annotations/NonNull.html) [BooleanSupplier](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/BooleanSupplier.html) stop)
Retries until the given stop function returns true.
7. [retryWhen](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html#retryWhen-io.reactivex.rxjava3.functions.Function-)([@NonNull](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/annotations/NonNull.html) [Function](http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/functions/Function.html),? extends org.reactivestreams.Publisher> handler)
Re-subscribes to the current Single if and when the Publisher returned by the handler function signals a value.
I would suggest to add support for 3,4,5 as in my opinion they seam as the most common and useful ones.
I would be willing to contribute this solution. This can be a nice addition to vertx5 API
Contributor guide
Assessment
This issue has not been assessed yet.