Skip to content

Commit

Permalink
chore: update after release v1.0.0-Alpha29 📦
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Nov 16, 2024
1 parent 525398c commit 09a068a
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 87 deletions.
64 changes: 17 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
<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=main&logo=github&logoColor=white&label=strong ci" alt="Github Workflow Build Status"></a>
<a href="https://app.codecov.io/gh/foldright/cffu/tree/main"><img src="https://img.shields.io/codecov/c/github/foldright/cffu/main?logo=codecov&logoColor=white" alt="Codecov"></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://kotlinlang.org"><img src="https://img.shields.io/badge/Kotlin-1.6+-7F52FF.svg?logo=kotlin&logoColor=white" alt="Kotlin"></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/cffu/"><img src="https://img.shields.io/github/release/foldright/cffu?label=javadoc&color=339933&logo=read-the-docs&logoColor=white" alt="Javadocs"></a>
<a href="https://foldright.io/api-docs/cffu-kotlin/"><img src="https://img.shields.io/github/release/foldright/cffu?label=dokka&color=339933&logo=kotlin&logoColor=white" alt="dokka"></a>
<a href="https://central.sonatype.com/artifact/io.foldright/cffu/0.9.0/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu?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" 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>
Expand Down Expand Up @@ -36,7 +34,7 @@
- [🔧 功能](#-%E5%8A%9F%E8%83%BD)
- [关于`CompletableFuture`](#%E5%85%B3%E4%BA%8Ecompletablefuture)
- [👥 User Guide](#-user-guide)
- [1. `cffu`的三种使用方式](#1-cffu%E7%9A%84%E4%B8%89%E7%A7%8D%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F)
- [1. `cffu`的使用方式](#1-cffu%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F)
- [2. `cffu`功能介绍](#2-cffu%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D)
- [2.1 返回多个`CF`的整体运行结果](#21-%E8%BF%94%E5%9B%9E%E5%A4%9A%E4%B8%AAcf%E7%9A%84%E6%95%B4%E4%BD%93%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C)
- [2.2 支持设置缺省的业务线程池并封装携带](#22-%E6%94%AF%E6%8C%81%E8%AE%BE%E7%BD%AE%E7%BC%BA%E7%9C%81%E7%9A%84%E4%B8%9A%E5%8A%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%B9%B6%E5%B0%81%E8%A3%85%E6%90%BA%E5%B8%A6)
Expand Down Expand Up @@ -98,7 +96,6 @@
- 工厂方法:`failedFuture` / `completedStage` / `failedStage`
- 处理操作:`completeAsync` / `exceptionallyAsync` / `exceptionallyCompose` / `copy`
- 非阻塞读:`resultNow` / `exceptionNow` / `state`
- 🍩 **一等公民支持`Kotlin`**

更多`cffu`的使用方式与功能说明详见 [User Guide](#-user-guide)

Expand Down Expand Up @@ -135,29 +132,26 @@

# 👥 User Guide

## 1. `cffu`的三种使用方式
## 1. `cffu`的使用方式

`cffu`支持三种使用方式
`cffu`的使用方式

- 🦝 1) **使用`Cffu`**
- 🦝 **使用`Cffu`**
- 项目使用`Java`语言时,推荐这种使用方式
- 直接使用`CompletableFuture`类的代码可以比较简单的迁移到`Cffu`类,包含2步修改:
- 在类型声明地方,由`CompletableFuture`改成`Cffu`
-`CompletableFuture`静态方法调用的地方,类名`CompletableFuture`改成`cffuFactory`实例
- 更多参见[如何从直接使用`CompletableFuture`类迁移到`Cffu`](#3-%E5%A6%82%E4%BD%95%E4%BB%8E%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8completablefuture%E7%B1%BB%E8%BF%81%E7%A7%BB%E5%88%B0cffu%E7%B1%BB)
- 依赖`io.foldright:cffu`
- 🛠️️ 2) **使用`CompletableFutureUtils`工具类**
- 🔧 **使用`CompletableFutureUtils`工具类**
- 如果你不想在项目中引入新类(`Cffu`类)、觉得这样增加了复杂性的话,
- 完全可以把`cffu`库作为一个工具类来用
- 优化`CompletableFuture`使用的工具方法在业务项目中很常见,`CompletableFutureUtils`提供了一系列实用可靠高效安全的工具方法
- 这种使用方式有些`cffu`功能没有提供(也没有想到实现方案) 😔
如支持设置缺省的业务线程池、禁止强制篡改
- 依赖`io.foldright:cffu`
- 🍩 3) **使用`Kotlin`扩展方法**
- 项目使用`Kotlin`语言时,推荐这种使用方式
- 要依赖`io.foldright:cffu-kotlin`

更多参见`cffu`三种使用方式的[示例代码](docs/usage-mode-demo.md)。 🎪
> `cffu`也支持`Kotlin`扩展方法的使用方式,参见[`cffu-kotlin/README.md`](cffu-kotlin/README.md);使用方式对比示例参见[`docs/usage-mode-demo.md`](docs/usage-mode-demo.md)
## 2. `cffu`功能介绍

Expand Down Expand Up @@ -515,13 +509,10 @@ public class MultipleActionsDemo {

可以参见:

- `API`文档
- [`Java API`文档](https://foldright.io/api-docs/cffu/)
- [`Kotlin API`文档](https://foldright.io/api-docs/cffu-kotlin/)
- [`Java API`文档](https://foldright.io/api-docs/cffu/)
- 实现源码
- `cffu`[`Cffu.java`](cffu-core/src/main/java/io/foldright/cffu/Cffu.java)[`CffuFactory.java`](cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java)
- `CompletableFuture utils`[`CompletableFutureUtils.java`](cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java)[`ListenableFutureUtils.java`](cffu-core/src/main/java/io/foldright/cffu/ListenableFutureUtils.java)
- `Kotlin extensions`[`CffuExtensions.kt`](cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt)[`CompletableFutureExtensions.kt`](cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt)[`ListenableFutureExtensions.kt`](cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/ListenableFutureExtensions.kt)
- [`CompletableFutureUtils.java`](cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java)

## 3. 如何从直接使用`CompletableFuture`类迁移到`Cffu`

Expand All @@ -538,7 +529,6 @@ public class MultipleActionsDemo {
# 🔌 API Docs

- 当前版本的`Java API`文档: https://foldright.io/api-docs/cffu/
- 当前版本的`Kotlin API`文档: https://foldright.io/api-docs/cffu-kotlin/

代码示例:

Expand All @@ -553,38 +543,18 @@ public class MultipleActionsDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu</artifactId>
<version>1.0.0-Alpha28</version>
<version>1.0.0-Alpha29</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu:1.0.0-Alpha28")
implementation("io.foldright:cffu:1.0.0-Alpha29")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu:1.0.0-Alpha28'
```
- `cffu Kotlin`支持库:
- For `Maven` projects:

```xml
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-kotlin</artifactId>
<version>1.0.0-Alpha28</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu-kotlin:1.0.0-Alpha28")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha28'
implementation 'io.foldright:cffu:1.0.0-Alpha29'
```
- `cffu bom`:
- For `Maven` projects:
Expand All @@ -593,7 +563,7 @@ public class MultipleActionsDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-bom</artifactId>
<version>1.0.0-Alpha28</version>
<version>1.0.0-Alpha29</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -602,11 +572,11 @@ public class MultipleActionsDemo {

```groovy
// Gradle Kotlin DSL
implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha28"))
implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha29"))
```
```groovy
// Gradle Groovy DSL
implementation platform('io.foldright:cffu-bom:1.0.0-Alpha28')
implementation platform('io.foldright:cffu-bom:1.0.0-Alpha29')
```
- [📌 `TransmittableThreadLocal(TTL)`](https://github.com/alibaba/transmittable-thread-local)的[`cffu executor wrapper SPI`实现](cffu-ttl-executor-wrapper):
- For `Maven` projects:
Expand All @@ -615,19 +585,19 @@ public class MultipleActionsDemo {
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
<version>1.0.0-Alpha28</version>
<version>1.0.0-Alpha29</version>
<scope>runtime</scope>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha28")
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha29")
```
```groovy
// Gradle Groovy DSL
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha28'
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha29'
```

# 📚 更多资料
Expand Down
5 changes: 0 additions & 5 deletions cffu-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
<artifactId>cffu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-kotlin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
Expand Down
34 changes: 34 additions & 0 deletions cffu-kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 🦝 `Cffu` kotlin support 🍩

<p align="center">
<a href="https://kotlinlang.org"><img src="https://img.shields.io/badge/Kotlin-1.6+-7F52FF.svg?logo=kotlin&logoColor=white" alt="Kotlin"></a>
<a href="https://central.sonatype.com/artifact/io.foldright/cffu-kotlin/0.9.0/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu-kotlin?logo=apache-maven&logoColor=white" alt="Maven Central"></a>
<a href="https://foldright.io/api-docs/cffu-kotlin/"><img src="https://img.shields.io/github/release/foldright/cffu?label=dokka&color=339933&logo=kotlin&logoColor=white" alt="dokka"></a>
</p>

This module provides the extension methods to leverage Kotlin language.

- `Kotlin API` documentation(dokka): https://foldright.io/api-docs/cffu-kotlin/
- `Kotlin extensions`:
- [`CffuExtensions.kt`](src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt)
- [`CompletableFutureExtensions.kt`](src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt)
- Dependency:
- For `Maven` projects:

```xml
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-kotlin</artifactId>
<version>1.0.0-Alpha29</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu-kotlin:1.0.0-Alpha29")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha29'
```
30 changes: 30 additions & 0 deletions cffu-listenable-future/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Guava ListenableFuture Integration to CompletableFuture

<p align="center">
<a href="https://central.sonatype.com/artifact/io.foldright/cffu-listenable-future/0.9.0/versions"><img src="https://img.shields.io/maven-central/v/io.foldright/cffu-listenable-future?logo=apache-maven&logoColor=white" alt="Maven Central"></a>
<a href="https://foldright.io/api-docs/cffu-listenable-future/"><img src="https://img.shields.io/github/release/foldright/cffu?label=dokka&color=339933&logo=kotlin&logoColor=white" alt="dokka"></a>
</p>

- Sources:
- [`ListenableFutureUtils.java`](src/main/java/io/foldright/cffu/lf/ListenableFutureUtils.java)
- [`ListenableFutureExtensions.kt`](src/main/java/io/foldright/cffu/lf/kotlin/ListenableFutureExtensions.kt)
- Dependency:
- For `Maven` projects:

```xml
<dependency>
<groupId>io.foldright</groupId>
<artifactId>cffu-listenable-future</artifactId>
<version>1.0.0-Alpha29</version>
</dependency>
```
- For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
implementation("io.foldright:cffu-listenable-future:1.0.0-Alpha29")
```
```groovy
// Gradle Groovy DSL
implementation 'io.foldright:cffu-listenable-future:1.0.0-Alpha29'
```
2 changes: 1 addition & 1 deletion cffu-listenable-future/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>cffu-listenable-future</artifactId>
<name>ListenableFuture Integration to CompletableFuture</name>
<name>Guava ListenableFuture Integration to CompletableFuture</name>
<description>${project.name}</description>
<url>https://github.com/foldright/cffu</url>
<inceptionYear>2023</inceptionYear>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.foldright.lf;
package io.foldright.cffu.lf;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.foldright.lf.kotlin
package io.foldright.cffu.lf.kotlin

import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.MoreExecutors
import io.foldright.cffu.Cffu
import io.foldright.cffu.CffuFactory
import io.foldright.lf.ListenableFutureUtils
import io.foldright.cffu.lf.ListenableFutureUtils
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executor

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.foldright.lf;
package io.foldright.cffu.lf;

import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
Expand All @@ -13,7 +13,7 @@
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

import static io.foldright.lf.ListenableFutureUtils.*;
import static io.foldright.cffu.lf.ListenableFutureUtils.*;
import static io.foldright.test_utils.TestUtils.*;
import static io.foldright.test_utils.TestingConstants.*;
import static io.foldright.test_utils.TestingExecutorUtils.testCffuFac;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.foldright.lf.kotlin
package io.foldright.cffu.lf.kotlin

import com.google.common.util.concurrent.Futures
import io.foldright.cffu.CompletableFutureUtils.failedFuture
import io.foldright.lf.kotlin.toCffu
import io.foldright.lf.kotlin.toCompletableFuture
import io.foldright.lf.kotlin.toListenableFuture
import io.foldright.cffu.lf.kotlin.toCffu
import io.foldright.cffu.lf.kotlin.toCompletableFuture
import io.foldright.cffu.lf.kotlin.toListenableFuture
import io.foldright.test_utils.n
import io.foldright.test_utils.rte
import io.foldright.test_utils.testCffuFac
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.foldright.lf.study
package io.foldright.cffu.lf.study

import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
Expand Down
6 changes: 3 additions & 3 deletions cffu-ttl-executor-wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ For `Maven` projects:
<groupId>io.foldright</groupId>
<artifactId>cffu-ttl-executor-wrapper</artifactId>
<scope>runtime</scope>
<version>1.0.0-Alpha28</version>
<version>1.0.0-Alpha29</version>
</dependency>
```

For `Gradle` projects:

```groovy
// Gradle Kotlin DSL
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha28")
runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha29")
```

```groovy
// Gradle Groovy DSL
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha28'
runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha29'
```

`cffu-ttl-executor-wrapper` has published to maven central, find the latest version at
Expand Down
33 changes: 12 additions & 21 deletions scripts/bump_cffu_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@ set -eEuo pipefail
SELF_PATH=$(realpath -- "$0")
readonly SELF_PATH SELF_DIR=${SELF_PATH%/*}
# cd to script dir
cd "$SELF_DIR"
cd "$SELF_DIR"/..

source "$PWD/bash-buddy/lib/trap_error_info.sh"
source "$PWD/bash-buddy/lib/common_utils.sh"
source "$PWD/bash-buddy/lib/java_utils.sh"
source "$PWD/bash-buddy/lib/maven_utils.sh"

readonly newline=$'\n'
source "$SELF_DIR/bash-buddy/lib/trap_error_info.sh"
source "$SELF_DIR/bash-buddy/lib/common_utils.sh"
source "$SELF_DIR/bash-buddy/lib/java_utils.sh"
source "$SELF_DIR/bash-buddy/lib/maven_utils.sh"

# shellcheck disable=SC2154
[ $# -ne 1 ] && cu::die "need only 1 argument for version!$newline${newline}usage:$newline $0 x.y.z"
readonly new_version="$1"

bump_cffu_version() {
mvu::mvn_cmd \
org.codehaus.mojo:versions-maven-plugin:2.15.0:set \
-DgenerateBackupPoms=false \
-DprocessAllModules=true \
-DnewVersion="$new_version"
}
[ $# -ne 2 ] && cu::die "need only 2 argument for old and new versions!"

cd ..
bump_cffu_version
readonly old_version="$1"
readonly new_version="$2"

cd demos
bump_cffu_version
# shellcheck disable=SC2046
sed -i "s/1.0.0-Alpha29/$new_version/g" $(rg 1.0.0-Alpha29 -l)
# shellcheck disable=SC2046
sed -i "s/$old_version/$new_version/g" $(rg "$old_version" -l)

0 comments on commit 09a068a

Please sign in to comment.