Loading repository dataβ¦
Loading repository dataβ¦
foldright / repository
π¦ Java CompletableFuture-Fu ("CF-Fu", pronounced "Shifu") is a tiny library that improves the CompletableFuture (CF) usage experience and reduces misuse, enabling more convenient, efficient, and safe use of CF in your application. πππ¦Ί
π English Documentation | π δΈζζζ‘£
π Java CompletableFuture-Fu ("CF-Fu", pronounced "Shifu" π¦) is a tiny library that improves
the CompletableFuture(CF)
usage experience and reduces misuse, enabling more convenient, efficient, and safe use of CF in your application. πππ¦Ί
Welcome ππ
cffu usage modes
cffu feature introduction
CFsCFs with fail-fast support, instead of futile waiting that reduces business responsivenessCFs, instead of the first completed but exceptional CFAllFailFast / AnySuccess / AllSuccess / MostSuccess)actions instead of wrapping them into Completablefutures firstβοΈ Completing missing functionality in business development
CFs
instead of returning CF<Void> without input CF results (CompletableFuture#allOf)
allResultsFailFastOf / mSupplyFailFastAsync / thenMApplyMostSuccessAsyncActions instead of wrapping them into CompletableFutures first
mSupplyAsync / mRunFailFastAsync / thenMApplyAllSuccessAsyncMISD) style processingCompletableFutures first
CfParallelUtils#parApplyFailFastAsync / CfParallelUtils#thenParAcceptAnySuccessAsyncSIMD) style processingCFs / Actions instead of converting them to array first
CfIterableUtils#allResultsFailFastOf /
CfIterableUtils#mSupplyFailFastAsync / CfIterableUtils#thenMApplyMostSuccessAsyncCffuFactory#builder(executor) method,
instead of repeatedly passing business thread pool parameters during async executioncatching methods
instead of handling all Throwable exceptions (CompletableFuture#exceptionally)AllFailFast strategy: fail fast when any of the multiple input CFs complete
exceptionally instead of futilely waiting for all CFs to complete (CompletableFuture#allOf)AnySuccess strategy: Return the first successful CF result
instead of the first completed but possibly exceptional CF (CompletableFuture#anyOf)AllSuccess strategy: Return successful results from multiple CFs,
returning specified default values for exceptional sβ³ Backport support for Java 8, all new CF methods from Java 9+ versions
are directly available in Java 8 version, such as:
orTimeout / completeOnTimeoutdelayedExecutorfailedFuture / completedStage / failedStagecompleteAsync / exceptionallyAsync / exceptionallyCompose / copyresultNow / exceptionNow / stateπͺ Enhancement of existing features, such as:
anyOf method: Returns specific type T (type-safe)
instead of returning Object (CompletableFuture#anyOf)allOf / anyOf methods: Accept broader CompletionStage parameter typeActionCompletableFutureCFMostSuccess strategy: Return successful results from multiple CFs within a specified time,
returning specified default values for exceptional or timed-out CFsAll(Complete) / Any(Complete) strategies: These two are strategies already supported by CompletableFutureorTimeout / completeOnTimeout methods
CF#orTimeout / CF#completeOnTimeout methods can break CompletableFuture's timeout and delay functionalityβοΈpeek processing method that definitely won't modify CF results
whenComplete method may modify the CF result,
and the returned CF result may not be consistent with the inputjoin(timeout, unit) methodobtrude methods via CffuFactoryBuilder#forbidObtrudeMethods methodIDEs to provide early problem warnings during coding
@NonNull, @Nullable, @CheckReturnValue, @Contract, etc.completeExceptionallyAsync methodCFs, getSuccessNow methodCF exceptions into business exceptions, unwrapCfException method