change back to chinese

This commit is contained in:
yedf2 2021-08-05 16:55:17 +08:00
parent 6b9d8407ac
commit 22108fbc6a
3 changed files with 184 additions and 194 deletions

View File

@ -1,123 +0,0 @@
![license](https://img.shields.io/github/license/yedf/dtm)
[![Build Status](https://travis-ci.com/yedf/dtm.svg?branch=main)](https://travis-ci.com/yedf/dtm)
[![Coverage Status](https://coveralls.io/repos/github/yedf/dtm/badge.svg?branch=main)](https://coveralls.io/github/yedf/dtm?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/yedf/dtm)](https://goreportcard.com/report/github.com/yedf/dtm)
[![Go Reference](https://pkg.go.dev/badge/github.com/yedf/dtm.svg)](https://pkg.go.dev/github.com/yedf/dtm)
# [English Docs](https://github.com/yedf/dtm/blob/main/README.md)
# [文档与教程](http://dtm.pub)
# GO语言分布式事务管理服务
DTM是首款golang的开源分布式事务管理器优雅的解决了幂等、空补偿、悬挂等分布式事务难题。提供了简单易用、高性能、易水平扩展的分布式事务解决方案。
受邀参加中国数据库大会分享[多语言环境下分布式事务实践](http://dtcc.it168.com/yicheng.html#b9)
## 谁在使用dtm
[Ivydad 常青藤爸爸](https://ivydad.com)
[Eglass 视咖镜小二](https://epeijing.cn)
## 亮点
* 极易接入
- 支持HTTP提供非常简单的接口极大降低上手分布式事务的难度新手也能快速接入
* 使用简单
- 开发者不再担心悬挂、空补偿、幂等各类问题,框架层代为处理
* 跨语言
- 可适合多语言栈的公司使用。方便go、python、php、nodejs、ruby、c# 各类语言使用。
* 易部署、易扩展
- 仅依赖mysql部署简单易集群化易水平扩展
* 多种分布式事务协议支持
- TCC、SAGA、XA、事务消息
## 与其他框架对比
目前开源的分布式事务框架暂未看到非Java语言有成熟的框架。而Java语言的较多有阿里的SEATA、华为的ServiceComb-Pack京东的shardingsphere以及himlytcc-transactionByteTCC等等其中以seata应用最为广泛。
下面是dtm和seata的主要特性对比
| 特性| DTM | SEATA |备注|
|:-----:|:----:|:----:|:----:|
| 支持语言 |<span style="color:green">Golang、python、php、c# 及其他</span>|<span style="color:orange">Java</span>|dtm可轻松接入一门新语言|
|异常处理| <span style="color:green">[子事务屏障自动处理](https://zhuanlan.zhihu.com/p/388444465)</span>|<span style="color:orange">手动处理</span> |dtm解决了幂等、悬挂、空补偿|
| TCC事务| <span style="color:green"></span>|<span style="color:green"></span>||
| XA事务|<span style="color:green"></span>|<span style="color:green"></span>||
|AT事务|<span style="color:red"></span>|<span style="color:green"></span>|AT与XA类似性能更好但有脏回滚|
| SAGA事务 |<span style="color:orange">简单模式</span> |<span style="color:green">状态机复杂模式</span> |dtm的状态机模式在规划中|
|事务消息|<span style="color:green"></span>|<span style="color:red"></span>|dtm提供类似rocketmq的事务消息|
|通信协议|HTTP|dubbo等协议无HTTP|dtm后续将支持grpc类协议|
|star数量|<img src="https://img.shields.io/github/stars/yedf/dtm.svg?style=social" alt="github stars"/>|<img src="https://img.shields.io/github/stars/seata/seata.svg?style=social" alt="github stars"/>|dtm从20210604发布0.1,发展快|
从上面对比的特性来看如果您的语言栈包含了Java之外的语言那么dtm是您的首选。如果您的语言栈是Java您也可以选择接入dtm使用子事务屏障技术简化您的业务编写。
## [各语言客户端及示例](./doc/sdk.md)
## 快速开始
### 安装
`git clone https://github.com/yedf/dtm`
### dtm依赖于mysql
配置mysql
`cp conf.sample.yml conf.yml # 修改conf.yml`
### 启动并运行saga示例
`go run app/main.go saga`
## 开始使用
### 使用
``` GO
// 具体业务微服务地址
const qsBusi = "http://localhost:8081/api/busi_saga"
req := &gin.H{"amount": 30} // 微服务的载荷
// DtmServer为DTM服务的地址是一个url
DtmServer := "http://localhost:8080/api/dtmsvr"
saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
// 添加一个TransOut的子事务正向操作为url: qsBusi+"/TransOut" 补偿操作为url: qsBusi+"/TransOutCompensate"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
// 添加一个TransIn的子事务正向操作为url: qsBusi+"/TransIn" 补偿操作为url: qsBusi+"/TransInCompensate"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
// 提交saga事务dtm会完成所有的子事务/回滚所有的子事务
err := saga.Submit()
```
成功运行后可以看到TransOut、TransIn依次被调用完成了整个分布式事务
### 时序图
上述saga分布式事务的时序图如下
<img src="https://pic3.zhimg.com/80/v2-b7d98659093c399e182a0173a8e549ca_1440w.jpg" height=428 />
### 完整示例
参考[examples/quick_start.go](./examples/quick_start.go)
## 文档与介绍(更新中)
* [分布式事务简介](https://zhuanlan.zhihu.com/p/387487859)
* 分布式事务模式
- [XA事务模式](https://zhuanlan.zhihu.com/p/384756957)
- [SAGA事务模式](https://zhuanlan.zhihu.com/p/385594256)
- [TCC事务模式](https://zhuanlan.zhihu.com/p/388357329)
- 可靠消息事务模式
* [子事务屏障](https://zhuanlan.zhihu.com/p/388444465)
* [通信协议](./doc/protocol.md)
* [FAQ](https://github.com/yedf/dtm/issues/1)
* 部署指南
## 交流群
请加 yedf2008 好友或者扫码加好友,验证回复 dtm 按照指引进群
![yedf2008](http://service.ivydad.com/cover/dubbingb6b5e2c0-2d2a-cd59-f7c5-c6b90aceb6f1.jpeg)
如果您觉得[dtm](https://github.com/yedf/dtm)不错,或者对您有帮助,请赏颗星吧!
## 谁在使用
<div style='vertical-align: middle'>
<img alt='常青藤爸爸' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img>
<img alt='镜小二' height='40' src='https://img.epeijing.cn/official-website/assets/logo.png' /img>
</div>

117
README-en.md Normal file
View File

@ -0,0 +1,117 @@
![license](https://img.shields.io/github/license/yedf/dtm)
[![Build Status](https://travis-ci.com/yedf/dtm.svg?branch=main)](https://travis-ci.com/yedf/dtm)
[![Coverage Status](https://coveralls.io/repos/github/yedf/dtm/badge.svg?branch=main)](https://coveralls.io/github/yedf/dtm?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/yedf/dtm)](https://goreportcard.com/report/github.com/yedf/dtm)
[![Go Reference](https://pkg.go.dev/badge/github.com/yedf/dtm.svg)](https://pkg.go.dev/github.com/yedf/dtm)
# [中文文档](http://dtm.pub)
# A lightweight distributed transaction manager
DTM is the first golang open source distributed transaction project. It elegantly resolve the problem of execution out of order. In the microservice architecture, a high-performance and easy-to-use distributed transaction solution is provided.
## Who's using dtm
[Ivydad 常青藤爸爸](https://ivydad.com)
[Eglass 视咖镜小二](https://epeijing.cn)
## Characteristic
* Stable and reliable
+ Tested in the production environment, unit test coverage is over 90%
* Simple to use
+ The interface is simple, developers no longer worry about suspension, null compensation, idempotence, etc., and the framework layer takes care of them.
* Multi language supported
+ It is suitable for companies with multi-language stacks. The protocol supports http. Convenient to use in various languages such as go, python, php, nodejs, ruby, c#.
* Easy to deploy, easy to expand
+ Only rely on mysql, easy to deploy, easy to expand horizontally
* Multiple distributed transaction protocol supported
+ TCC: Try-Confirm-Cancel
+ SAGA:
+ Reliable news
+ XA
## dtm vs other
At present, the open source distributed transaction framework has not yet seen a mature framework for non-Java languages. There are many Java projects, such as Ali's SEATA, Huawei's ServiceComb-Pack, JD's shardingsphere, and himly, tcc-transaction, ByteTCC, etc. Among them, seata is the most widely used.
The following is a comparison of the main features of dtm and seata:
| Features | DTM | SEATA | Remarks |
|:-----:|:----:|:----:|:----:|
| Supported languages| <span style="color:green">Golang, python, php, c# and others</span> | <span style="color:orange">Java</span> |dtm can easily support a new language|
|Exception Handling| <span style="color:green">[Sub-transaction barrier automatic processing](./doc/barrier-en.md)</span>|<span style="color:orange">Manual processing</span> | dtm solves idempotence, suspension, and null compensation|
| TCC| <span style="color:green"></span>|<span style="color:green"></span>||
| XA|<span style="color:green"></span>|<span style="color:green"></span>||
|AT |<span style="color:red"></span>|<span style="color:green"></span>|AT is similar to XA, with better performance but dirty rollback|
| SAGA |<span style="color:orange">simple mode</span> |<span style="color:green">state machine complex mode</span> |dtm's state machine mode is under planning|
|Transaction message|<span style="color:green"></span>|<span style="color:red"></span>|dtm provides transaction messages similar to rocketmq|
|Communication protocol|HTTP|dubbo and other protocols, no HTTP|dtm will support grpc protocol in the future|
|star number|<img src="https://img.shields.io/github/stars/yedf/dtm.svg?style=social" alt="github stars"/>|<img src="https://img.shields.io/github/stars/seata/seata.svg?style=social" alt="github stars"/>|dtm releases 0.1 from 20210604, fast development|
From the features of the comparison above, if your language stack includes languages other than Java, then dtm is your first choice. If your language stack is Java, you can also choose to access dtm and use sub-transaction barrier technology to simplify your business writing.
# Quick start
### Installation
`git clone https://github.com/yedf/dtm`
### DTM depends on mysql
Configure mysql:
`cp conf.sample.yml conf.yml # Modify conf.yml`
### Start and run the saga example
`go run app/main.go`
# Start using
### Use
``` go
// business microservice address
const qsBusi = "http://localhost:8081/api/busi_saga"
req := &gin.H{"amount": 30} // Microservice payload
// The address where DtmServer serves DTM, which is a url
DtmServer := "http://localhost:8080/api/dtmsvr"
saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
// Add a TransOut sub-transaction, the operation is url: qsBusi+"/TransOut"
// compensation operation is url: qsBusi+"/TransOutCompensate"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
// Add a TransIn sub-transaction, the operation is url: qsBusi+"/TransOut"
// compensation operation is url: qsBusi+"/TransInCompensate"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
// Submit the saga transaction, dtm will complete all sub-transactions/rollback all sub-transactions
err := saga.Submit()
```
### Complete example
Refer to [examples/quick_start.go](./examples/quick_start.go)
### [sub-transaction barrier](./doc/barrier-en.md)
### [protocol](./doc/protocol-en.md)
### Wechat Group
Please add wechat yedf2008 friends or scan the code to add friends
![yedf2008](http://service.ivydad.com/cover/dubbingb6b5e2c0-2d2a-cd59-f7c5-c6b90aceb6f1.jpeg)
If you think this project is good, or helpful to you, please give a star!
### Who is using
<div style='vertical-align: middle'>
<img alt='ivydad' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img>
<img alt='eglass' height='40' src='https://img.epeijing.cn/official-website/assets/logo.png' /img>
</div>
### Following is keyword for SEO
分布式事务框架
事务消息
可靠消息
微服务

138
README.md
View File

@ -4,114 +4,110 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/yedf/dtm)](https://goreportcard.com/report/github.com/yedf/dtm) [![Go Report Card](https://goreportcard.com/badge/github.com/yedf/dtm)](https://goreportcard.com/report/github.com/yedf/dtm)
[![Go Reference](https://pkg.go.dev/badge/github.com/yedf/dtm.svg)](https://pkg.go.dev/github.com/yedf/dtm) [![Go Reference](https://pkg.go.dev/badge/github.com/yedf/dtm.svg)](https://pkg.go.dev/github.com/yedf/dtm)
# [中文文档](http://dtm.pub) # [English Docs](https://github.com/yedf/dtm/blob/main/README-en.md)
# [文档与教程](http://dtm.pub)
# GO语言分布式事务管理服务
# A lightweight distributed transaction manager DTM是首款golang的开源分布式事务管理器优雅的解决了幂等、空补偿、悬挂等分布式事务难题。提供了简单易用、高性能、易水平扩展的分布式事务解决方案。
DTM is the first golang open source distributed transaction project. It elegantly resolve the problem of execution out of order. In the microservice architecture, a high-performance and easy-to-use distributed transaction solution is provided. 受邀参加中国数据库大会分享[多语言环境下分布式事务实践](http://dtcc.it168.com/yicheng.html#b9)
## Who's using dtm ## 谁在使用dtm
[Ivydad 常青藤爸爸](https://ivydad.com) [Ivydad 常青藤爸爸](https://ivydad.com)
[Eglass 视咖镜小二](https://epeijing.cn) [Eglass 视咖镜小二](https://epeijing.cn)
## Characteristic ## 亮点
* Stable and reliable * 极易接入
+ Tested in the production environment, unit test coverage is over 90% - 支持HTTP提供非常简单的接口极大降低上手分布式事务的难度新手也能快速接入
* Simple to use * 使用简单
+ The interface is simple, developers no longer worry about suspension, null compensation, idempotence, etc., and the framework layer takes care of them. - 开发者不再担心悬挂、空补偿、幂等各类问题,框架层代为处理
* Multi language supported * 跨语言
+ It is suitable for companies with multi-language stacks. The protocol supports http. Convenient to use in various languages such as go, python, php, nodejs, ruby, c#. - 可适合多语言栈的公司使用。方便go、python、php、nodejs、ruby、c# 各类语言使用。
* Easy to deploy, easy to expand * 易部署、易扩展
+ Only rely on mysql, easy to deploy, easy to expand horizontally - 仅依赖mysql部署简单易集群化易水平扩展
* Multiple distributed transaction protocol supported * 多种分布式事务协议支持
+ TCC: Try-Confirm-Cancel - TCC、SAGA、XA、事务消息
+ SAGA:
+ Reliable news
+ XA
## dtm vs other ## 与其他框架对比
At present, the open source distributed transaction framework has not yet seen a mature framework for non-Java languages. There are many Java projects, such as Ali's SEATA, Huawei's ServiceComb-Pack, JD's shardingsphere, and himly, tcc-transaction, ByteTCC, etc. Among them, seata is the most widely used. 目前开源的分布式事务框架暂未看到非Java语言有成熟的框架。而Java语言的较多有阿里的SEATA、华为的ServiceComb-Pack京东的shardingsphere以及himlytcc-transactionByteTCC等等其中以seata应用最为广泛。
The following is a comparison of the main features of dtm and seata: 下面是dtm和seata的主要特性对比
| Features | DTM | SEATA | Remarks | | 特性| DTM | SEATA |备注|
|:-----:|:----:|:----:|:----:| |:-----:|:----:|:----:|:----:|
| Supported languages| <span style="color:green">Golang, python, php, c# and others</span> | <span style="color:orange">Java</span> |dtm can easily support a new language| | 支持语言 |<span style="color:green">Golang、python、php、c# 及其他</span>|<span style="color:orange">Java</span>|dtm可轻松接入一门新语言|
|Exception Handling| <span style="color:green">[Sub-transaction barrier automatic processing](./doc/barrier-en.md)</span>|<span style="color:orange">Manual processing</span> | dtm solves idempotence, suspension, and null compensation| |异常处理| <span style="color:green">[子事务屏障自动处理](https://zhuanlan.zhihu.com/p/388444465)</span>|<span style="color:orange">手动处理</span> |dtm解决了幂等、悬挂、空补偿|
| TCC| <span style="color:green"></span>|<span style="color:green"></span>|| | TCC事务| <span style="color:green"></span>|<span style="color:green"></span>||
| XA|<span style="color:green"></span>|<span style="color:green"></span>|| | XA事务|<span style="color:green"></span>|<span style="color:green"></span>||
|AT |<span style="color:red"></span>|<span style="color:green"></span>|AT is similar to XA, with better performance but dirty rollback| |AT事务|<span style="color:red"></span>|<span style="color:green"></span>|AT与XA类似性能更好但有脏回滚|
| SAGA |<span style="color:orange">simple mode</span> |<span style="color:green">state machine complex mode</span> |dtm's state machine mode is under planning| | SAGA事务 |<span style="color:orange">简单模式</span> |<span style="color:green">状态机复杂模式</span> |dtm的状态机模式在规划中|
|Transaction message|<span style="color:green"></span>|<span style="color:red"></span>|dtm provides transaction messages similar to rocketmq| |事务消息|<span style="color:green"></span>|<span style="color:red"></span>|dtm提供类似rocketmq的事务消息|
|Communication protocol|HTTP|dubbo and other protocols, no HTTP|dtm will support grpc protocol in the future| |通信协议|HTTP|dubbo等协议无HTTP|dtm后续将支持grpc类协议|
|star number|<img src="https://img.shields.io/github/stars/yedf/dtm.svg?style=social" alt="github stars"/>|<img src="https://img.shields.io/github/stars/seata/seata.svg?style=social" alt="github stars"/>|dtm releases 0.1 from 20210604, fast development| |star数量|<img src="https://img.shields.io/github/stars/yedf/dtm.svg?style=social" alt="github stars"/>|<img src="https://img.shields.io/github/stars/seata/seata.svg?style=social" alt="github stars"/>|dtm从20210604发布0.1,发展快|
From the features of the comparison above, if your language stack includes languages other than Java, then dtm is your first choice. If your language stack is Java, you can also choose to access dtm and use sub-transaction barrier technology to simplify your business writing. 从上面对比的特性来看如果您的语言栈包含了Java之外的语言那么dtm是您的首选。如果您的语言栈是Java您也可以选择接入dtm使用子事务屏障技术简化您的业务编写。
## [教程与文档](http://dtm.pub)
## [各语言客户端及示例](./doc/sdk.md)
## 快速开始
### 安装
# Quick start
### Installation
`git clone https://github.com/yedf/dtm` `git clone https://github.com/yedf/dtm`
### DTM depends on mysql
Configure mysql: ### dtm依赖于mysql
`cp conf.sample.yml conf.yml # Modify conf.yml` 配置mysql
### Start and run the saga example `cp conf.sample.yml conf.yml # 修改conf.yml`
`go run app/main.go`
# Start using ### 启动并运行saga示例
`go run app/main.go saga`
### Use ## 开始使用
``` go
// business microservice address ### 使用
``` GO
// 具体业务微服务地址
const qsBusi = "http://localhost:8081/api/busi_saga" const qsBusi = "http://localhost:8081/api/busi_saga"
req := &gin.H{"amount": 30} // Microservice payload req := &gin.H{"amount": 30} // 微服务的载荷
// The address where DtmServer serves DTM, which is a url // DtmServer为DTM服务的地址是一个url
DtmServer := "http://localhost:8080/api/dtmsvr" DtmServer := "http://localhost:8080/api/dtmsvr"
saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)). saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
// Add a TransOut sub-transaction, the operation is url: qsBusi+"/TransOut" // 添加一个TransOut的子事务正向操作为url: qsBusi+"/TransOut" 补偿操作为url: qsBusi+"/TransOutCompensate"
// compensation operation is url: qsBusi+"/TransOutCompensate"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req). Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
// Add a TransIn sub-transaction, the operation is url: qsBusi+"/TransOut" // 添加一个TransIn的子事务正向操作为url: qsBusi+"/TransIn" 补偿操作为url: qsBusi+"/TransInCompensate"
// compensation operation is url: qsBusi+"/TransInCompensate"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req) Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
// Submit the saga transaction, dtm will complete all sub-transactions/rollback all sub-transactions // 提交saga事务dtm会完成所有的子事务/回滚所有的子事务
err := saga.Submit() err := saga.Submit()
``` ```
### Complete example
Refer to [examples/quick_start.go](./examples/quick_start.go) 成功运行后可以看到TransOut、TransIn依次被调用完成了整个分布式事务
### [sub-transaction barrier](./doc/barrier-en.md) ### 时序图
### [protocol](./doc/protocol-en.md) 上述saga分布式事务的时序图如下
### Wechat Group <img src="https://pic3.zhimg.com/80/v2-b7d98659093c399e182a0173a8e549ca_1440w.jpg" height=428 />
Please add wechat yedf2008 friends or scan the code to add friends ### 完整示例
参考[examples/quick_start.go](./examples/quick_start.go)
## 交流群
请加 yedf2008 好友或者扫码加好友,验证回复 dtm 按照指引进群
![yedf2008](http://service.ivydad.com/cover/dubbingb6b5e2c0-2d2a-cd59-f7c5-c6b90aceb6f1.jpeg) ![yedf2008](http://service.ivydad.com/cover/dubbingb6b5e2c0-2d2a-cd59-f7c5-c6b90aceb6f1.jpeg)
If you think this project is good, or helpful to you, please give a star! 如果您觉得[dtm](https://github.com/yedf/dtm)不错,或者对您有帮助,请赏颗星吧!
### Who is using ## 谁在使用
<div style='vertical-align: middle'> <div style='vertical-align: middle'>
<img alt='ivydad' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img> <img alt='常青藤爸爸' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img>
<img alt='eglass' height='40' src='https://img.epeijing.cn/official-website/assets/logo.png' /img> <img alt='镜小二' height='40' src='https://img.epeijing.cn/official-website/assets/logo.png' /img>
</div> </div>
### Following is keyword for SEO
分布式事务框架
事务消息
可靠消息
微服务