Cffu
๐ฆ 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. ๐๐๐ฆบ
Install / Use
/learn @foldright/CffuREADME
<div align="center"><a href="#dummy"><img src="https://github.com/foldright/cffu/assets/1063891/124658cd-025f-471e-8da1-7eea0e482915" alt="๐ฆ CompletableFuture-Fu(CF-Fu)"></a></div>
<p align="center"> <a href="https://github.com/foldright/cffu/actions/workflows/fast_ci.yaml"><img src="https://img.shields.io/github/actions/workflow/status/foldright/cffu/fast_ci.yaml?branch=2.x-dev&logo=github&logoColor=white&label=fast%20ci" alt="Fast Build CI"></a> <a href="https://github.com/foldright/cffu/actions/workflows/ci.yaml"><img src="https://img.shields.io/github/actions/workflow/status/foldright/cffu/ci.yaml?branch=2.x-dev&logo=github&logoColor=white&label=strong%20ci" alt="Strong Build CI"></a> <a href="https://app.codecov.io/gh/foldright/cffu/tree/2.x-dev"><img src="https://img.shields.io/codecov/c/github/foldright/cffu/2.x-dev?logo=codecov&logoColor=white" alt="Codecov"></a> <a href="https://qodana.cloud/projects/A61Yy/reports?branch=2.x-dev"><img src="https://img.shields.io/github/actions/workflow/status/foldright/cffu/qodana_code_quality.yml?branch=2.x-dev&logo=jetbrains&logoColor=white&label=qodana" alt="Qodana Code Inspections"></a> <a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-8+-339933?logo=openjdk&logoColor=white" alt="Java support"></a> <a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/foldright/cffu?color=4D7A97&logo=apache" alt="License"></a> <a href="https://foldright.io/api-docs/cffu2/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=read-the-docs&logoColor=white&filter=v2.*" alt="Javadocs"></a> <a href="https://central.sonatype.com/artifact/io.foldright/cffu2/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu2?logo=apache-maven&logoColor=white" alt="Maven Central"></a> <a href="https://github.com/foldright/cffu/releases"><img src="https://img.shields.io/github/release/foldright/cffu.svg?filter=v2.*" alt="GitHub Releases"></a> <a href="https://github.com/foldright/cffu/stargazers"><img src="https://img.shields.io/github/stars/foldright/cffu?style=flat" alt="GitHub Stars"></a> <a href="https://github.com/foldright/cffu/fork"><img src="https://img.shields.io/github/forks/foldright/cffu?style=flat" alt="GitHub Forks"></a> <a href="https://github.com/foldright/cffu/issues"><img src="https://img.shields.io/github/issues/foldright/cffu" alt="GitHub Issues"></a> <a href="https://github.com/foldright/cffu/graphs/contributors"><img src="https://img.shields.io/github/contributors/foldright/cffu" alt="GitHub Contributors"></a> <a href="https://github.com/foldright/cffu"><img src="https://img.shields.io/github/repo-size/foldright/cffu" alt="GitHub repo size"></a> <a href="https://gitpod.io/#https://github.com/foldright/cffu"><img src="https://img.shields.io/badge/Gitpod-ready to code-339933?label=gitpod&logo=gitpod&logoColor=white" alt="gitpod: Ready to Code"></a> </p>๐ 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 ๐๐
<a href="#dummy"><img src="https://user-images.githubusercontent.com/1063891/230850403-87ff74de-1acb-4aff-b9b4-632e4e51e225.png" width="23%" align="right" alt="shifu" /></a>
- For suggestions and questions, submit an Issue
- For contributions and improvements, play fork and pull request dance
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- ๐ง Features
- ๐ฅ User Guide
- 1.
cffuusage modes - 2.
cffufeature introduction- 2.1 support for returning overall results of multiple input
CFs - 2.2 retrieve all results of multiple
CFs with fail-fast support, instead of futile waiting that reduces business responsiveness - 2.3 retrieve the first successful result from multiple
CFs, instead of the first completed but exceptionalCF - 2.4 support for setting the default business thread pool
- 2.5 efficient and flexible concurrent execution strategies (
AllFailFast/AnySuccess/AllSuccess/MostSuccess) - 2.6 support for directly running multiple
actions instead of wrapping them intoCompletablefutures first - 2.7 Support for async parallel processing of collection data, instead of wrapping data and
ActionintoCompletableFutures first - 2.8 support for handling specific exception types instead of all
Throwableexceptions - 2.9 backport support for
Java 8 - 2.10 timeout-safe new implementation of
orTimeout/completeOnTimeout - 2.11 support for timeout-enabled
joinmethod - 2.12
anyOfmethod that returns specific types - 2.13
allOf/anyOfmethods that accept broader input types - more feature documentation
- 2.1 support for returning overall results of multiple input
- 3. Orchestration Methods of
cffulibrary and Best Practices
- 1.
- ๐ API Docs
- ๐ช Dependencies
- ๐ More Resources
- ๐ About the Library Name
๐ง Features
โ๏ธ Completing missing functionality in business development
- ๐ช More convenient features, such as:
- Support for returning overall results of multiple input
CFs instead of returningCF<Void>without inputCFresults (CompletableFuture#allOf)- Such as methods
allResultsFailFastOf/mSupplyFailFastAsync/thenMApplyMostSuccessAsync
- Such as methods
- Support for directly running multiple
Actions instead of wrapping them intoCompletableFutures first- Such as methods
mSupplyAsync/mRunFailFastAsync/thenMApplyAllSuccessAsync - i.e. multiple instruction, single data (
MISD) style processing
- Such as methods
- Support for async parallel processing of collection data,
instead of wrapping data with actions into
CompletableFutures first- Such as methods
CfParallelUtils#parApplyFailFastAsync/CfParallelUtils#thenParAcceptAnySuccessAsync - i.e. single instruction, multiple data (
SIMD) style processing
- Such as methods
- Support for inputting collections of
CFs /Actions instead of converting them to array first- Such as methods
CfIterableUtils#allResultsFailFastOf/CfIterableUtils#mSupplyFailFastAsync/CfIterableUtils#thenMApplyMostSuccessAsync
- Such as methods
- Support for setting a default business thread pool via
CffuFactory#builder(executor)method, instead of repeatedly passing business thread pool parameters during async execution - Support for handling specific exception types via
catchingmethods instead of handling allThrowableexceptions (CompletableFuture#exceptionally)
- Support for returning overall results of multiple input
- ๐ฆ More efficient and flexible concurrent execution strategies, such as:
AllFailFaststrategy: fail fast when any of the multiple inputCFs complete exceptionally instead of futilely waiting for allCFs to complete (CompletableFuture#allOf)AnySuccessstrategy: Return the first successfulCFresult instead of the first completed but possibly exceptionalCF(CompletableFuture#anyOf)AllSuccessstrategy: Return successful results from multipleCFs, returning specified default values for exceptionalCFsMostSuccessstrategy: Return successful results from multipleCFs within a specified time, returning specified default values for exceptional or timed-outCFsAll(Complete)/Any(Complete)
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot ๅฏๅชไฝๆถๅ่ฝๅใไฝฟ็จ <qqmedia> ๆ ็ญพ๏ผ็ณป็ปๆ นๆฎๆไปถๆฉๅฑๅ่ชๅจ่ฏๅซ็ฑปๅ๏ผๅพ็/่ฏญ้ณ/่ง้ข/ๆไปถ๏ผใ
