Copilot commented on code in PR #1105: URL: https://github.com/apache/incubator-seata-go/pull/1105#discussion_r3057997986
########## docs/quickstart.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go Quick Start + +## Prerequisites + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 Review Comment: `PostgreSQL / MySQL >= 8.0` is likely inaccurate because '8.0' corresponds to MySQL, not PostgreSQL. Consider splitting into separate bullets and listing the correct minimum versions per database (or omitting the PostgreSQL version constraint if it’s not intended). ```suggestion - PostgreSQL - MySQL >= 8.0 ``` ########## docs/quickstart.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go Quick Start + +## Prerequisites + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### Start Seata Server (Binary) + +1. Download the binary distribution from the official [Seata-Server Release History](https://seata.apache.org/release-history/seata-server/) page and extract it. +2. Enter the extracted Seata Server directory. +3. Start the server with `file` storage mode: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`: specifies the Seata Server port. +> - `-h 127.0.0.1`: specifies the registry or advertised server address. +> - `-m file`: stores transaction logs in `file` mode, which is suitable for a local quick start. + +4. Confirm that Seata Server is running and listening on `127.0.0.1:8091`. + +### Start Seata Server (Docker) + +1. Pull the image from the official Docker Hub repository [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server): + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. Start a container from the image you just pulled: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> If local Docker has limited available memory and startup fails with `There is insufficient memory for the Java Runtime Environment to continue` or `Cannot allocate memory`, you can explicitly lower the JVM heap size, for example: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> Add `-d` if you want to run it in the background. + +3. Check the logs and confirm that the service is ready: + +```bash +docker logs -f seata-server +``` + +4. Confirm that the client can reach `127.0.0.1:8091` before continuing. + +If you later need to switch Seata Server to Nacos or another registry center, adjust the Seata Server-side `registry.conf` and `application.yaml`. + +If your Seata Server uses Nacos, Seata Server 1.4.x and earlier server-side configuration is usually written in `registry.conf`, for example: + +```hocon +registry { + type = "nacos" + nacos { + application = "seata-server" + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + cluster = "default" + username = "" + password = "" + } +} + +config { + type = "nacos" + nacos { + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + username = "" + password = "" + } +} +``` + +> `registry.conf`: official parameter reference and Nacos config-center example: [Parameter Configuration](https://seata.apache.org/docs/user/configurations) · [Nacos Configuration Center](https://seata.apache.org/docs/user/configuration/nacos/) + +Seata Server 1.4.x and later usually uses `application.yaml` as the server-side configuration file in the Nacos scenario: Review Comment: The version ranges overlap at `1.4.x` (both '1.4.x and earlier' and '1.4.x and later'). Please adjust the boundary so it’s unambiguous (e.g., '1.4.x and earlier' vs '1.5.0+' or whatever the correct cutoff is per Seata Server). ```suggestion Seata Server 1.5.0 and later usually uses `application.yaml` as the server-side configuration file in the Nacos scenario: ``` ########## docs/quickstart.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go Quick Start + +## Prerequisites + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### Start Seata Server (Binary) + +1. Download the binary distribution from the official [Seata-Server Release History](https://seata.apache.org/release-history/seata-server/) page and extract it. +2. Enter the extracted Seata Server directory. +3. Start the server with `file` storage mode: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`: specifies the Seata Server port. +> - `-h 127.0.0.1`: specifies the registry or advertised server address. +> - `-m file`: stores transaction logs in `file` mode, which is suitable for a local quick start. + +4. Confirm that Seata Server is running and listening on `127.0.0.1:8091`. + +### Start Seata Server (Docker) + +1. Pull the image from the official Docker Hub repository [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server): + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. Start a container from the image you just pulled: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> If local Docker has limited available memory and startup fails with `There is insufficient memory for the Java Runtime Environment to continue` or `Cannot allocate memory`, you can explicitly lower the JVM heap size, for example: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> Add `-d` if you want to run it in the background. + +3. Check the logs and confirm that the service is ready: + +```bash +docker logs -f seata-server +``` + +4. Confirm that the client can reach `127.0.0.1:8091` before continuing. + +If you later need to switch Seata Server to Nacos or another registry center, adjust the Seata Server-side `registry.conf` and `application.yaml`. + +If your Seata Server uses Nacos, Seata Server 1.4.x and earlier server-side configuration is usually written in `registry.conf`, for example: Review Comment: The version ranges overlap at `1.4.x` (both '1.4.x and earlier' and '1.4.x and later'). Please adjust the boundary so it’s unambiguous (e.g., '1.4.x and earlier' vs '1.5.0+' or whatever the correct cutoff is per Seata Server). ```suggestion If your Seata Server uses Nacos, Seata Server 1.4.x and earlier server-side configuration is usually written in `registry.conf`, while Seata Server 1.5.0 and later usually uses `application.yaml`. For 1.4.x and earlier, for example: ``` ########## docs/quickstart_zh.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go 快速开始 + +## 环境准备 + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### 启动 Seata Server(二进制) + +1. 从 Seata 官网的 [Seata-Server 版本历史](https://seata.apache.org/zh-cn/release-history/seata-server/) 页面下载二进制发行包并解压。 +2. 进入解压后的 Seata Server 目录。 +3. 使用 `file` 存储模式启动服务: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`:指定 Seata Server 端口。 +> - `-h 127.0.0.1`:指定服务注册地址或对外暴露地址。 +> - `-m file`:使用 `file` 模式存储事务日志,适合本地快速开始。 + +4. 确认 Seata Server 成功启动并监听 `127.0.0.1:8091`。 + +### 启动 Seata Server(Docker) + +1. 从 Docker Hub 官方仓库 [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server) 拉取镜像: + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. 使用刚刚拉取的镜像启动容器: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> 如果本地 Docker 可用内存较小,启动时出现 `There is insufficient memory for the Java Runtime Environment to continue` 或 `Cannot allocate memory`,可以显式调低 JVM 堆大小,例如: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> 如需后台运行,可额外添加 `-d`。 + +3. 查看启动日志,确认服务已就绪: + +```bash +docker logs -f seata-server +``` + +4. 确认客户端可以访问 `127.0.0.1:8091`。 + +如果后面需要将 Seata Server 切换到 Nacos 或其他注册中心,可对照 Seata Server 侧的 `registry.conf` 与 `application.yaml` 进行修改。 + +如果你的 Seata Server 使用 Nacos 部署,Seata Server 1.4.x 及以前的服务端配置通常写在 `registry.conf` 中,例如: + +```hocon +registry { + type = "nacos" + nacos { + application = "seata-server" + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + cluster = "default" + username = "" + password = "" + } +} + +config { + type = "nacos" + nacos { + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + username = "" + password = "" + } +} +``` + +> `registry.conf`:官方参数总表与 Nacos 配置中心示例:[参数配置](https://seata.apache.org/zh-cn/docs/user/configurations) · [Nacos 配置中心](https://seata.apache.org/zh-cn/docs/user/configuration/nacos/) + +Seata Server 1.4.x 及以后在 Nacos 场景下通常使用 `application.yaml` 作为服务端配置文件: + +```yaml +seata: + registry: + type: nacos + nacos: + application: seata-server + server-addr: 127.0.0.1:8848 + group: SEATA_GROUP + namespace: "" + cluster: default + username: "" + password: "" + config: + type: nacos + nacos: + server-addr: 127.0.0.1:8848 + group: SEATA_GROUP + namespace: "" + data-id: seataServer.properties + username: "" + password: "" +``` + +> `application.yaml`:官方参数总表与 Nacos 注册中心示例:[参数配置](https://seata.apache.org/zh-cn/docs/user/configurations) · [Nacos 注册中心](https://seata.apache.org/zh-cn/docs/user/registry/nacos/) + +`seatago.yml` 是当前仓库的 Seata Go 客户端配置文件,用于调整客户端的注册中心、事务分组与服务地址。例如: + +```yaml +seata: + application-id: quickstart-demo + tx-service-group: default_tx_group + data-source-proxy-mode: AT + + service: + vgroup-mapping: + default_tx_group: default + grouplist: + default: 127.0.0.1:8091 + + registry: + type: file + + client: + tm: + default-global-transaction-timeout: 60s + rm: + lock: + retry-interval: 30s + retry-times: 10 + retry-policy-branch-rollback-on-conflict: true + undo: + log-serialization: json + log-table: undo_log + only-care-update-columns: true + + tcc: + fence: + enable: false +``` + +配置结构与完整样例参考如下: + +- `seatago.yml`:[配置结构定义](../pkg/client/config.go) · [完整样例](../testdata/conf/seatago.yml) + +## 快速集成 + +安装依赖: + +```bash +go get seata.apache.org/seata-go/v2@latest +``` + +初始化 Seata 客户端: + +```go +package main + +import ( + "context" + + "seata.apache.org/seata-go/v2/pkg/client" + "seata.apache.org/seata-go/v2/pkg/tm" +) + +func main() { + // 初始化 Seata 客户端 + client.InitPath("./conf/seatago.yml") + // 或者先设置 SEATA_GO_CONFIG_PATH=/path/to/you/seatago.yml,再调用: Review Comment: Correct 'you' to 'your' in the example path. ```suggestion // 或者先设置 SEATA_GO_CONFIG_PATH=/path/to/your/seatago.yml,再调用: ``` ########## docs/quickstart.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go Quick Start + +## Prerequisites + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### Start Seata Server (Binary) + +1. Download the binary distribution from the official [Seata-Server Release History](https://seata.apache.org/release-history/seata-server/) page and extract it. +2. Enter the extracted Seata Server directory. +3. Start the server with `file` storage mode: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file Review Comment: Step 2 says to enter the extracted Seata Server directory, but step 3 runs `./seata-server/bin/seata-server.sh`, which likely points to a nested `seata-server` folder and will fail for typical Seata distributions (where `bin/seata-server.sh` is directly under the extracted directory). Update the command (or step 2) so the path matches the expected extracted layout. ```suggestion sh ./bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file ``` ########## docs/quickstart_zh.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go 快速开始 + +## 环境准备 + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### 启动 Seata Server(二进制) + +1. 从 Seata 官网的 [Seata-Server 版本历史](https://seata.apache.org/zh-cn/release-history/seata-server/) 页面下载二进制发行包并解压。 +2. 进入解压后的 Seata Server 目录。 +3. 使用 `file` 存储模式启动服务: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`:指定 Seata Server 端口。 +> - `-h 127.0.0.1`:指定服务注册地址或对外暴露地址。 +> - `-m file`:使用 `file` 模式存储事务日志,适合本地快速开始。 + +4. 确认 Seata Server 成功启动并监听 `127.0.0.1:8091`。 + +### 启动 Seata Server(Docker) + +1. 从 Docker Hub 官方仓库 [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server) 拉取镜像: + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. 使用刚刚拉取的镜像启动容器: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> 如果本地 Docker 可用内存较小,启动时出现 `There is insufficient memory for the Java Runtime Environment to continue` 或 `Cannot allocate memory`,可以显式调低 JVM 堆大小,例如: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> 如需后台运行,可额外添加 `-d`。 + +3. 查看启动日志,确认服务已就绪: + +```bash +docker logs -f seata-server +``` + +4. 确认客户端可以访问 `127.0.0.1:8091`。 + +如果后面需要将 Seata Server 切换到 Nacos 或其他注册中心,可对照 Seata Server 侧的 `registry.conf` 与 `application.yaml` 进行修改。 + +如果你的 Seata Server 使用 Nacos 部署,Seata Server 1.4.x 及以前的服务端配置通常写在 `registry.conf` 中,例如: Review Comment: 这里对版本范围的描述在 `1.4.x` 上有重叠(既属于“及以前”,也属于“及以后”)。建议把分界版本改成不重叠的写法(例如明确到 `1.4.x` / `1.5.0+`,以 Seata Server 实际变更为准),避免读者困惑。 ```suggestion 如果你的 Seata Server 使用 Nacos 部署,Seata Server 1.4.x 的服务端配置通常写在 `registry.conf` 中,例如: ``` ########## docs/quickstart_zh.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go 快速开始 + +## 环境准备 + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### 启动 Seata Server(二进制) + +1. 从 Seata 官网的 [Seata-Server 版本历史](https://seata.apache.org/zh-cn/release-history/seata-server/) 页面下载二进制发行包并解压。 +2. 进入解压后的 Seata Server 目录。 +3. 使用 `file` 存储模式启动服务: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file Review Comment: 第 2 步写的是进入解压后的 Seata Server 目录,但第 3 步命令使用 `./seata-server/bin/seata-server.sh`,这通常会指向一个嵌套的 `seata-server` 目录,和常见发行包目录结构不匹配(一般脚本在当前目录的 `bin/seata-server.sh`)。建议统一第 2 步与命令路径,避免读者直接执行失败。 ```suggestion sh ./bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file ``` ########## docs/quickstart.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go Quick Start + +## Prerequisites + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### Start Seata Server (Binary) + +1. Download the binary distribution from the official [Seata-Server Release History](https://seata.apache.org/release-history/seata-server/) page and extract it. +2. Enter the extracted Seata Server directory. +3. Start the server with `file` storage mode: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`: specifies the Seata Server port. +> - `-h 127.0.0.1`: specifies the registry or advertised server address. +> - `-m file`: stores transaction logs in `file` mode, which is suitable for a local quick start. + +4. Confirm that Seata Server is running and listening on `127.0.0.1:8091`. + +### Start Seata Server (Docker) + +1. Pull the image from the official Docker Hub repository [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server): + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. Start a container from the image you just pulled: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> If local Docker has limited available memory and startup fails with `There is insufficient memory for the Java Runtime Environment to continue` or `Cannot allocate memory`, you can explicitly lower the JVM heap size, for example: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> Add `-d` if you want to run it in the background. + +3. Check the logs and confirm that the service is ready: + +```bash +docker logs -f seata-server +``` + +4. Confirm that the client can reach `127.0.0.1:8091` before continuing. + +If you later need to switch Seata Server to Nacos or another registry center, adjust the Seata Server-side `registry.conf` and `application.yaml`. + +If your Seata Server uses Nacos, Seata Server 1.4.x and earlier server-side configuration is usually written in `registry.conf`, for example: + +```hocon +registry { + type = "nacos" + nacos { + application = "seata-server" + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + cluster = "default" + username = "" + password = "" + } +} + +config { + type = "nacos" + nacos { + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + username = "" + password = "" + } +} +``` + +> `registry.conf`: official parameter reference and Nacos config-center example: [Parameter Configuration](https://seata.apache.org/docs/user/configurations) · [Nacos Configuration Center](https://seata.apache.org/docs/user/configuration/nacos/) + +Seata Server 1.4.x and later usually uses `application.yaml` as the server-side configuration file in the Nacos scenario: + +```yaml +seata: + registry: + type: nacos + nacos: + application: seata-server + server-addr: 127.0.0.1:8848 + group: SEATA_GROUP + namespace: "" + cluster: default + username: "" + password: "" + config: + type: nacos + nacos: + server-addr: 127.0.0.1:8848 + group: SEATA_GROUP + namespace: "" + data-id: seataServer.properties + username: "" + password: "" +``` + +> `application.yaml`: official parameter reference and Nacos registry example: [Parameter Configuration](https://seata.apache.org/docs/user/configurations) · [Nacos Registry Center](https://seata.apache.org/docs/user/registry/nacos/) + +`seatago.yml` is the Seata Go client configuration file in this repository. Use it to adjust the client-side registry center, transaction group, and server address. For example: + +```yaml +seata: + application-id: quickstart-demo + tx-service-group: default_tx_group + data-source-proxy-mode: AT + + service: + vgroup-mapping: + default_tx_group: default + grouplist: + default: 127.0.0.1:8091 + + registry: + type: file + + client: + tm: + default-global-transaction-timeout: 60s + rm: + lock: + retry-interval: 30s + retry-times: 10 + retry-policy-branch-rollback-on-conflict: true + undo: + log-serialization: json + log-table: undo_log + only-care-update-columns: true + + tcc: + fence: + enable: false +``` + +References for the configuration structure and a full sample: + +- `seatago.yml`: [Config struct](../pkg/client/config.go) · [Full sample](../testdata/conf/seatago.yml) + +## Quick Integration + +Install the dependency: + +```bash +go get seata.apache.org/seata-go/v2@latest +``` + +Initialize the Seata client: + +```go +package main + +import ( + "context" + + "seata.apache.org/seata-go/v2/pkg/client" + "seata.apache.org/seata-go/v2/pkg/tm" +) + +func main() { + // Initialize the Seata client + client.InitPath("./conf/seatago.yml") + // Or set SEATA_GO_CONFIG_PATH=/path/to/your/seatago.yml first, then call: + // client.Init() + + ctx := context.Background() + + // Run business logic in a global transaction + err := tm.WithGlobalTx(ctx, &tm.GtxConfig{Name: "my-tx"}, func(ctx context.Context) error { + // Business logic + return nil + }) + if err != nil { + panic(err) + } +} +``` + +## Example Scenarios + +### AT Example + +AT mode wraps business logic with `tm.WithGlobalTx(...)` and uses the `seata-at-mysql` driver to intercept database access: + +```go +db, err := sql.Open( + "seata-at-mysql", + "root:password@tcp(127.0.0.1:3306)/seata_demo?charset=utf8mb4&parseTime=True&multiStatements=true", +) Review Comment: This example uses `sql.Open(...)` but the snippet doesn’t show importing `database/sql` (and it may also require a driver side-effect import depending on how `seata-at-mysql` is registered). Consider adding the minimal imports (or a note like 'imports omitted') to avoid copy/paste confusion for new users. ########## docs/quickstart_zh.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go 快速开始 + +## 环境准备 + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 + +### 启动 Seata Server(二进制) + +1. 从 Seata 官网的 [Seata-Server 版本历史](https://seata.apache.org/zh-cn/release-history/seata-server/) 页面下载二进制发行包并解压。 +2. 进入解压后的 Seata Server 目录。 +3. 使用 `file` 存储模式启动服务: + +```bash +sh ./seata-server/bin/seata-server.sh -p 8091 -h 127.0.0.1 -m file +``` + +> - `-p 8091`:指定 Seata Server 端口。 +> - `-h 127.0.0.1`:指定服务注册地址或对外暴露地址。 +> - `-m file`:使用 `file` 模式存储事务日志,适合本地快速开始。 + +4. 确认 Seata Server 成功启动并监听 `127.0.0.1:8091`。 + +### 启动 Seata Server(Docker) + +1. 从 Docker Hub 官方仓库 [`apache/seata-server`](https://hub.docker.com/r/apache/seata-server) 拉取镜像: + +```bash +docker pull apache/seata-server:<seata-version> +``` + +2. 使用刚刚拉取的镜像启动容器: + +```bash +docker run --name seata-server \ + -p 8091:8091 \ + -e STORE_MODE=file \ + apache/seata-server:<seata-version> +``` + +> 如果本地 Docker 可用内存较小,启动时出现 `There is insufficient memory for the Java Runtime Environment to continue` 或 `Cannot allocate memory`,可以显式调低 JVM 堆大小,例如: +> +> ```bash +> docker run --name seata-server \ +> -p 8091:8091 \ +> -e STORE_MODE=file \ +> -e JVM_XMS=512m \ +> -e JVM_XMX=512m \ +> apache/seata-server:<seata-version> +> ``` +> +> 如需后台运行,可额外添加 `-d`。 + +3. 查看启动日志,确认服务已就绪: + +```bash +docker logs -f seata-server +``` + +4. 确认客户端可以访问 `127.0.0.1:8091`。 + +如果后面需要将 Seata Server 切换到 Nacos 或其他注册中心,可对照 Seata Server 侧的 `registry.conf` 与 `application.yaml` 进行修改。 + +如果你的 Seata Server 使用 Nacos 部署,Seata Server 1.4.x 及以前的服务端配置通常写在 `registry.conf` 中,例如: + +```hocon +registry { + type = "nacos" + nacos { + application = "seata-server" + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + cluster = "default" + username = "" + password = "" + } +} + +config { + type = "nacos" + nacos { + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + username = "" + password = "" + } +} +``` + +> `registry.conf`:官方参数总表与 Nacos 配置中心示例:[参数配置](https://seata.apache.org/zh-cn/docs/user/configurations) · [Nacos 配置中心](https://seata.apache.org/zh-cn/docs/user/configuration/nacos/) + +Seata Server 1.4.x 及以后在 Nacos 场景下通常使用 `application.yaml` 作为服务端配置文件: Review Comment: 这里对版本范围的描述在 `1.4.x` 上有重叠(既属于“及以前”,也属于“及以后”)。建议把分界版本改成不重叠的写法(例如明确到 `1.4.x` / `1.5.0+`,以 Seata Server 实际变更为准),避免读者困惑。 ```suggestion Seata Server 1.5.0 及以后在 Nacos 场景下通常使用 `application.yaml` 作为服务端配置文件: ``` ########## README.md: ########## @@ -115,6 +115,7 @@ The latest tag / release is the latest stable version. ## Documentation +[Quick Start](./docs/quickstart.md) You can view the full documentation from Seata Official Website: [Seata Website page](https://seata.apache.org/zh-cn/docs/overview/what-is-seata). Review Comment: The English README points to a `zh-cn` documentation URL. If an English equivalent exists, consider using the non-`zh-cn` link to avoid sending English readers to the Chinese docs. ```suggestion You can view the full documentation from Seata Official Website: [Seata Website page](https://seata.apache.org/docs/overview/what-is-seata). ``` ########## docs/quickstart_zh.md: ########## @@ -0,0 +1,278 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Seata-go 快速开始 + +## 环境准备 + +- Go >= 1.20 +- Java >= 8 +- PostgreSQL / MySQL >= 8.0 Review Comment: 这一条 `PostgreSQL / MySQL >= 8.0` 可能不准确:`8.0` 通常是 MySQL 的版本表达,不适用于 PostgreSQL。建议拆分成两条分别写清楚最低版本(或如果 PostgreSQL 不限定版本,就不要写 `>= 8.0`)。 ```suggestion - PostgreSQL - MySQL >= 8.0 ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
