This is an automated email from the ASF dual-hosted git repository.
songxiaosheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-spi-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new 9b48975 add auddo-wasm/README_zh.md (#298)
9b48975 is described below
commit 9b48975e2e8c5d996bc25319fe7c93f0e3582be0
Author: 王聪洋 <[email protected]>
AuthorDate: Wed Mar 27 13:33:25 2024 +0800
add auddo-wasm/README_zh.md (#298)
* add auddo-wasm/README_zh.md
* add common README and cross-thread README_ch
---------
Co-authored-by: xiaosheng <[email protected]>
---
dubbo-common-extensions/README.md | 22 ++++++
dubbo-common-extensions/README_ch.md | 24 +++++++
dubbo-cross-thread-extensions/README.md | 1 +
.../{README.md => README_ch.md} | 33 +++++----
dubbo-tag-extensions/README.md | 2 +-
dubbo-tag-extensions/README_zh.md | 2 +-
dubbo-wasm/README.md | 8 ++-
dubbo-wasm/{README.md => README_zh.md} | 80 ++++++++++++----------
8 files changed, 114 insertions(+), 58 deletions(-)
diff --git a/dubbo-common-extensions/README.md
b/dubbo-common-extensions/README.md
new file mode 100644
index 0000000..b1fdc04
--- /dev/null
+++ b/dubbo-common-extensions/README.md
@@ -0,0 +1,22 @@
+# Dubbo Common Extensions
+[中文](./README_ch.md)
+
+Dubbo common utility class extensions, also providing testing functionalities.
+
+Adding Utils utility class, providing checks for presence of zero-argument
constructors and whether a class is provided by JDK.
+
+## How to Use?
+### Current Version: 3.2.0
+
+```
+<dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-common-extensions</artifactId>
+ <version>${dubbo-api-docs-version}</version>
+</dependency>
+```
+Directly call methods provided by the Utils class:
+```
+boolean haveZeroArgConstructor =
Utils.checkZeroArgConstructor(TestAClass.class)
+boolean isJdk = Utils.isJdk(String.class)
+```
diff --git a/dubbo-common-extensions/README_ch.md
b/dubbo-common-extensions/README_ch.md
new file mode 100644
index 0000000..7177fc3
--- /dev/null
+++ b/dubbo-common-extensions/README_ch.md
@@ -0,0 +1,24 @@
+# dubbo common extensions
+
+[English](./README.md)
+
+dubbo 共用工具类扩展,并提供测试功能.
+
+增加Utils工具类,提供是否有无参构造方法和是否是JDK提供类的检查
+
+## 如何使用?
+
+### 当前版本: 3.2.0
+
+```
+<dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-common-extensions</artifactId>
+ <version>${dubbo-api-docs-version}</version>
+</dependency>
+```
+直接调用Utils类提供的方法:
+```
+boolean haveZeroArgConstructor =
Utils.checkZeroArgConstructor(TestAClass.class)
+boolean isJdk = Utils.isJdk(String.class)
+```
diff --git a/dubbo-cross-thread-extensions/README.md
b/dubbo-cross-thread-extensions/README.md
index 4be849a..59399be 100644
--- a/dubbo-cross-thread-extensions/README.md
+++ b/dubbo-cross-thread-extensions/README.md
@@ -1,4 +1,5 @@
# Dubbo Cross Thread Extensions
+[中文](./README_ch.md)
`dubbo-cross-thread-extensions` copy dubbo.tag cross thread lightly .
it can run with skywalking and ttl .
diff --git a/dubbo-cross-thread-extensions/README.md
b/dubbo-cross-thread-extensions/README_ch.md
similarity index 88%
copy from dubbo-cross-thread-extensions/README.md
copy to dubbo-cross-thread-extensions/README_ch.md
index 4be849a..c30d004 100644
--- a/dubbo-cross-thread-extensions/README.md
+++ b/dubbo-cross-thread-extensions/README_ch.md
@@ -1,11 +1,13 @@
-# Dubbo Cross Thread Extensions
+# Dubbo 跨线程扩展
-`dubbo-cross-thread-extensions` copy dubbo.tag cross thread lightly .
-it can run with skywalking and ttl .
+[English](./README.md)
-## Integrate example
-### scan annotation by byte-buddy
-(you can install with ByteBuddyAgent or use it with `-javaagent=<agentjar>`)
+`dubbo-cross-thread-extensions` 轻量级地复制了 dubbo.tag 的跨线程功能。
+它可以与 SkyWalking 和 TTL 一起运行。
+
+## 集成示例
+### 使用 Byte Buddy 扫描注解
+(您可以使用 ByteBuddyAgent 安装或者使用 `-javaagent=<agentjar>` 进行使用)
```
Instrumentation instrumentation = ByteBuddyAgent.install();
RunnableOrCallableActivation.install(instrumentation);
@@ -19,7 +21,7 @@ it can run with skywalking and ttl .
ExecutorService threadPool = Executors.newSingleThreadExecutor();
Future<String> result = threadPool.submit(callable);
```
-### add annotation @DubboCrossThread
+### 添加注解 @DubboCrossThread
```
@DubboCrossThread
@@ -30,7 +32,7 @@ public class TargetClass implements Runnable{
}
}
```
-### wrap Callable or Runnable
+### 包装 Callable 或 Runnable
```
Callable<String> callable = CallableWrapper.of(new Callable<String>() {
@Override
@@ -47,9 +49,9 @@ Runnable runnable = RunnableWrapper.of(new Runnable() {
}
});
```
-## Integrate with spring boot
+## 与 Spring Boot 集成
-### add a listener
+### 添加一个监听器
```
public class DubboCrossThreadAnnotationListener implements
ApplicationListener<ApplicationEnvironmentPreparedEvent> {
private Logger logger =
LoggerFactory.getLogger(DubboCrossThreadAnnotationListener.class);
@@ -71,7 +73,7 @@ public class DubboCrossThreadAnnotationListener implements
ApplicationListener<A
}
```
-### install ByteBuddyAgent
+### 安装 ByteBuddyAgent
```
@SpringBootApplication
@ComponentScan(basePackages = "org.apache.your-package")
@@ -85,8 +87,8 @@ public class SpringBootDemoApplication {
}
```
-## run with skywalking and ttl
-jvm arguments:
+## 与 SkyWalking 和 TTL 一起运行
+JVM 参数:
```
-javaagent:transmittable-thread-local-2.14.2.jar
-Dskywalking.agent.application_code=tracecallable-ltf1
@@ -94,7 +96,7 @@ jvm arguments:
-Dskywalking.collector.backend_service=172.37.66.195:11800
-javaagent:skywalking-agent.jar
```
-example code:
+示例代码:
```
public class MultiAnnotationWithSwTtl {
private static TransmittableThreadLocal<String> context = new
TransmittableThreadLocal<>();
@@ -131,7 +133,7 @@ public class MultiAnnotationWithSwTtl {
}
```
-output:
+输出:
```
parent thread traceId=60cfc24e245d4389b9f40b5b38c33ef6.1.16910355654660001
dubbo.tag=tagValue
@@ -139,3 +141,4 @@ children thread
traceId=60cfc24e245d4389b9f40b5b38c33ef6.1.16910355654660001
ttl context.get()=value-set-in-parent with ttl
```
+
diff --git a/dubbo-tag-extensions/README.md b/dubbo-tag-extensions/README.md
index 8051960..5d40544 100644
--- a/dubbo-tag-extensions/README.md
+++ b/dubbo-tag-extensions/README.md
@@ -1,6 +1,6 @@
# dubbo tag subnets
-[中文](./README.md)
+[中文](./README_zh.md)
dubbo-tag-subnets will generate a tag by subnets, then consumer will prefer
rpc provider in the same subnets.
diff --git a/dubbo-tag-extensions/README_zh.md
b/dubbo-tag-extensions/README_zh.md
index e3c31db..2b05790 100644
--- a/dubbo-tag-extensions/README_zh.md
+++ b/dubbo-tag-extensions/README_zh.md
@@ -1,6 +1,6 @@
# dubbo tag subnets
-[中文](./README.md)
+[English](./README.md)
dubbo-tag-subnets 会根据子网生成tag, 然后同子网内的tag相同, 服务调用会优先发生在同子网中.
diff --git a/dubbo-wasm/README.md b/dubbo-wasm/README.md
index 7e981c4..7ea3858 100644
--- a/dubbo-wasm/README.md
+++ b/dubbo-wasm/README.md
@@ -1,5 +1,7 @@
# dubbo WASM api
+[中文](./README_zh.md)
+
At present, Dubbo's SPI extensions can only be written in Java language, the
dubbo-wasm module aims to overcome this limitation.
WASM(WebAssembly) bytecode is designed to be encoded in a size- and
load-time-efficient binary format. WASM aims to leverage the common hardware
features available on various platforms to execute in browsers at machine code
speed.
@@ -20,7 +22,7 @@ We use
[wasmtime-java](https://github.com/kawamuray/wasmtime-java) to run WASI i
## Note
-Due to the strict requirements of WASM on parameter types and for simplicity
reasons, types other than `java.lang.Long`/`java.lang.Integerr` are not used as
parameters or return value.
+Due to the strict requirements of WASM on parameter types and for simplicity
reasons, types other than `java.lang.Long`/`java.lang.Integer` are not used as
parameters or return value.
## How to use
@@ -75,7 +77,7 @@ You will see
`{your_subproject_name}/target/wasm32-wasi/release/{your_subproject
</dependency>
```
-### 6.Add x.y.z.RustLoadBalance.java
+### 6.Add `x.y.z.RustLoadBalance.java`
```java
package x.y.z;
@@ -85,7 +87,7 @@ public class RustLoadBalance extends AbstractWasmLoadBalance {
}
```
-### 7.Add resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance
+### 7.Add `resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance`
```text
rust=x.y.z.RustLoadBalance
diff --git a/dubbo-wasm/README.md b/dubbo-wasm/README_zh.md
similarity index 65%
copy from dubbo-wasm/README.md
copy to dubbo-wasm/README_zh.md
index 7e981c4..e6b22de 100644
--- a/dubbo-wasm/README.md
+++ b/dubbo-wasm/README_zh.md
@@ -1,38 +1,41 @@
# dubbo WASM api
-At present, Dubbo's SPI extensions can only be written in Java language, the
dubbo-wasm module aims to overcome this limitation.
+[English](./README.md)
-WASM(WebAssembly) bytecode is designed to be encoded in a size- and
load-time-efficient binary format. WASM aims to leverage the common hardware
features available on various platforms to execute in browsers at machine code
speed.
+目前,Dubbo的SPI扩展只能使用Java语言编写,dubbo-wasm模块旨在克服这一限制。
-WASI(WebAssembly System Interface) provide a portable interface for
applications that run within a constrained sandbox environment, which allows
WASM to run in non browser environments such as Linux. It's portable and secure.
+WASM(WebAssembly)字节码设计为以大小和高效加载时间的二进制格式编码。WASM旨在利用各种平台上可用的通用硬件特性,在浏览器中以机器码速度执行。
-We use [wasmtime-java](https://github.com/kawamuray/wasmtime-java) to run WASI
in Java, as long as the language can be compiled into WASM bytecode, it can be
used to write SPI extensions for dubbo.
+WASI(WebAssembly系统接口)为在受限沙箱环境中运行的应用程序提供了一个可移植接口,这使得WASM可以在非浏览器环境(如Linux)中运行。它具有可移植性和安全性。
-## Module structure
+我们使用 [wasmtime-java](https://github.com/kawamuray/wasmtime-java)
在Java中运行WASI,只要语言可以编译成WASM字节码,就可以用于编写dubbo的SPI扩展。
-* dubbo-wasm-api: Responsible for defining basic exceptions and providing
runtime for executing WASM bytecode (Dubbo API)
-* dubbo-wasm-cluster-api: Provide the WASM version of the dubbo-cluster module
SPIs
-* dubbo-wasm-common-api: Provide the WASM version of the dubbo-common module
SPIs
-* dubbo-wasm-metrics-api(todo): Provide the WASM version of the dubbo-metrics
module SPIs
-* dubbo-wasm-registry-api: Provide the WASM version of the dubbo-registry-api
module SPIs
-* dubbo-wasm-remoting-api(todo): Provide the WASM version of the
dubbo-remoting-api module SPIs
-* dubbo-wasm-rpc-api: Provide the WASM version of the dubbo-rpc-api module SPIs
+## 模块结构
-## Note
+* dubbo-wasm-api:负责定义基本异常并提供执行WASM字节码的运行时(Dubbo API)
+* dubbo-wasm-cluster-api:提供dubbo-cluster模块SPI的WASM版本
+* dubbo-wasm-common-api:提供dubbo-common模块SPI的WASM版本
+* dubbo-wasm-metrics-api(待办):提供dubbo-metrics模块SPI的WASM版本
+* dubbo-wasm-registry-api:提供dubbo-registry-api模块SPI的WASM版本
+* dubbo-wasm-remoting-api(待办):提供dubbo-remoting-api模块SPI的WASM版本
+* dubbo-wasm-rpc-api:提供dubbo-rpc-api模块SPI的WASM版本
-Due to the strict requirements of WASM on parameter types and for simplicity
reasons, types other than `java.lang.Long`/`java.lang.Integerr` are not used as
parameters or return value.
+## 注意事项
-## How to use
+由于WASM对参数类型有严格要求,并且为了简单起见,除了 `java.lang.Long/java.lang.Integer` 之外的类型不用作参数或返回值。
-Below is an example of implementing `org.apache.dubbo.rpc.cluster.LoadBalance`
SPI in rust.
+## 如何使用
-### 1.Create subproject in another language
+以下是在rust中实现 `org.apache.dubbo.rpc.cluster.LoadBalance` SPI的示例。
+
+
+### 1.用其他语言创建子项目
```shell
cargo new --lib your_subproject_name
```
-### 2.Add methods to lib.rs
+### 2.在lib.rs中添加方法
```rust
// Adding `#[no_mangle]` to prevent the Rust compiler from modifying method
names is mandatory
@@ -42,7 +45,8 @@ pub unsafe extern "C" fn doSelect(_arg_id: i64) -> i32 {
}
```
-### 3.Add `[lib]` to `Cargo.toml` and change `crate-type` to `["cdylib"]`.
Ultimately, your `Cargo.toml` should look like
+### 3.在 `Cargo.toml` 中添加 `[lib]` 并将 `crate-type` 更改为 `["cdylib"]`。最终,你的
`Cargo.toml` 应如下所示:
+
```toml
[package]
@@ -57,15 +61,15 @@ edition = "2021"
crate-type = ["cdylib"]
```
-### 4.Generate the wasm file
+### 4.生成 wasm 文件
```shell
cargo build --target wasm32-wasi --release
```
-You will see
`{your_subproject_name}/target/wasm32-wasi/release/{your_subproject_name}.wasm`.
+你可以看到
`{your_subproject_name}/target/wasm32-wasi/release/{your_subproject_name}.wasm`.
-### 5.Add dependency to `pom.xml`
+### 5.添加依赖到 `pom.xml`
```xml
<dependency>
@@ -75,7 +79,7 @@ You will see
`{your_subproject_name}/target/wasm32-wasi/release/{your_subproject
</dependency>
```
-### 6.Add x.y.z.RustLoadBalance.java
+### 6.添加 `x.y.z.RustLoadBalance.java`
```java
package x.y.z;
@@ -85,23 +89,23 @@ public class RustLoadBalance extends
AbstractWasmLoadBalance {
}
```
-### 7.Add resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance
+### 7.添加 `resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance`
```text
rust=x.y.z.RustLoadBalance
```
-### 8.Rename the WASM file
+### 8.重命名 WASM 文件
-Due to the class `x.y.z.RustLoadBalance.java`,the final wasm file name should
be `x.y.z.RustLoadBalance.wasm`, finally, put the wasm file in the `resources`
folder of your module.
+由于类 `x.y.z.RustLoadBalance.java`,最终的wasm文件名应该是
`x.y.z.RustLoadBalance.wasm`,最后将 wasm 文件放在你模块的 `resources` 文件夹中。
-## Communicate with Java
+## 与Java通信
-Below is an example of using rust.
+以下是使用rust的示例。
-### Pass args to another language
+### 将参数传递给另一种语言
-#### 1.Export method to another language
+#### 1.将方法导出到另一种语言
```java
public class RustLoadBalance extends AbstractWasmLoadBalance {
@@ -127,7 +131,7 @@ public class RustLoadBalance extends
AbstractWasmLoadBalance {
}
```
-#### 2.Import method in another language
+#### 2.在另一种语言中导入方法
```rust
#[link(wasm_import_module = "dubbo")]
@@ -136,7 +140,7 @@ extern "C" {
}
```
-#### 3.Get args in another language
+#### 3.在另一种语言中获取参数
```rust
#[no_mangle]
@@ -153,11 +157,11 @@ pub unsafe extern "C" fn doSelect(arg_id: i64) -> i32 {
}
```
-### Pass result to Java
+### 将结果传递给Java
-Below is an example of using rust.
+以下是使用rust的示例。
-#### 1.Export method to another language
+#### 1.将方法导出到另一种语言
```java
public class RustLoadBalance extends AbstractWasmLoadBalance {
@@ -188,7 +192,7 @@ public class RustLoadBalance extends
AbstractWasmLoadBalance {
}
```
-#### 2.Import method in another language
+#### 2.在另一种语言中导入方法
```rust
#[link(wasm_import_module = "dubbo")]
@@ -197,7 +201,7 @@ extern "C" {
}
```
-#### 3.Pass result in another language
+#### 3.在另一种语言中传递结果
```rust
#[no_mangle]
@@ -210,7 +214,7 @@ pub unsafe extern "C" fn doSelect(arg_id: i64) -> i32 {
}
```
-#### 4.Get result in Java
+#### 4.在Java中获取结果
```java
public class RustLoadBalance extends AbstractWasmLoadBalance {