Merge branch 'main' into alpha
This commit is contained in:
commit
fcc0eff799
13
README-en.md
13
README-en.md
@ -46,16 +46,17 @@ Configure mysql:
|
|||||||
``` go
|
``` go
|
||||||
// business microservice address
|
// business microservice address
|
||||||
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} // Microservice payload
|
||||||
// The address where DtmServer serves DTM, which is a url
|
// The address where DtmServer serves DTM, which is a url
|
||||||
saga := dtmcli.NewSaga("http://localhost:8080/api/dtmsvr").
|
DtmServer := "http://localhost:8080/api/dtmsvr"
|
||||||
|
saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
|
||||||
// Add a TransOut sub-transaction, the operation is url: qsBusi+"/TransOut",
|
// Add a TransOut sub-transaction, the operation is url: qsBusi+"/TransOut",
|
||||||
// compensation operation is 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",
|
// Add a TransIn sub-transaction, the operation is url: qsBusi+"/TransOut",
|
||||||
// compensation operation is 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
|
// Submit the saga transaction, dtm will complete all sub-transactions/rollback all sub-transactions
|
||||||
err := saga.Submit()
|
err := saga.Submit()
|
||||||
```
|
```
|
||||||
### Complete example
|
### Complete example
|
||||||
|
|||||||
34
README.md
34
README.md
@ -8,10 +8,23 @@
|
|||||||
|
|
||||||
# GO语言分布式事务管理服务
|
# GO语言分布式事务管理服务
|
||||||
|
|
||||||
DTM是首款golang的开源分布式事务管理器,优雅的解决了幂等、空补偿、悬挂等分布式事务难题。提供了高性能和简单易用的分布式事务解决方案。
|
DTM是首款golang的开源分布式事务管理器,优雅的解决了幂等、空补偿、悬挂等分布式事务难题。提供了简单易用、高性能、易水平扩展的分布式事务解决方案。
|
||||||
|
|
||||||
受邀参加中国数据库大会分享[多语言环境下分布式事务实践](http://dtcc.it168.com/yicheng.html#b9)
|
受邀参加中国数据库大会分享[多语言环境下分布式事务实践](http://dtcc.it168.com/yicheng.html#b9)
|
||||||
|
|
||||||
|
## 亮点
|
||||||
|
|
||||||
|
* 极易接入
|
||||||
|
- 支持HTTP,提供非常简单的接口,极大降低上手分布式事务的难度,新手也能快速接入
|
||||||
|
* 使用简单
|
||||||
|
- 开发者不再担心悬挂、空补偿、幂等各类问题,框架层代为处理
|
||||||
|
* 跨语言
|
||||||
|
- 可适合多语言栈的公司使用。方便go、python、php、nodejs、ruby各类语言使用。
|
||||||
|
* 易部署、易扩展
|
||||||
|
- 仅依赖mysql,部署简单,易集群化,易水平扩展
|
||||||
|
* 多种分布式事务协议支持
|
||||||
|
- TCC、SAGA、XA、事务消息
|
||||||
|
|
||||||
## 与其他框架对比
|
## 与其他框架对比
|
||||||
|
|
||||||
目前开源的分布式事务框架,暂未看到非Java语言有成熟的框架。而Java语言的较多,有阿里的SEATA、华为的ServiceComb-Pack,京东的shardingsphere,以及himly,tcc-transaction,ByteTCC等等,其中以seata应用最为广泛。
|
目前开源的分布式事务框架,暂未看到非Java语言有成熟的框架。而Java语言的较多,有阿里的SEATA、华为的ServiceComb-Pack,京东的shardingsphere,以及himly,tcc-transaction,ByteTCC等等,其中以seata应用最为广泛。
|
||||||
@ -24,7 +37,7 @@ DTM是首款golang的开源分布式事务管理器,优雅的解决了幂等
|
|||||||
|异常处理| <font color=green>[子事务屏障自动处理](https://zhuanlan.zhihu.com/p/388444465)</font>|<font color=orange>手动处理</font> |dtm解决了幂等、悬挂、空补偿|
|
|异常处理| <font color=green>[子事务屏障自动处理](https://zhuanlan.zhihu.com/p/388444465)</font>|<font color=orange>手动处理</font> |dtm解决了幂等、悬挂、空补偿|
|
||||||
| TCC事务| <font color=green>✓</font>|<font color=green>✓</font>||
|
| TCC事务| <font color=green>✓</font>|<font color=green>✓</font>||
|
||||||
| XA事务|<font color=green>✓</font>|<font color=green>✓</font>||
|
| XA事务|<font color=green>✓</font>|<font color=green>✓</font>||
|
||||||
|AT事务|<font color=red>✗</font>|<font color=green>✓</font>|AT与XA类似,性能更好|
|
|AT事务|<font color=red>✗</font>|<font color=green>✓</font>|AT与XA类似,性能更好,但有脏回滚|
|
||||||
| SAGA事务 | <font color=orange>简单模式</font> | <font color=green>状态机复杂模式</font> |dtm的状态机模式在规划中|
|
| SAGA事务 | <font color=orange>简单模式</font> | <font color=green>状态机复杂模式</font> |dtm的状态机模式在规划中|
|
||||||
|事务消息|<font color=green>✓</font>|<font color=red>✗</font>|dtm提供类似rocketmq的事务消息|
|
|事务消息|<font color=green>✓</font>|<font color=red>✗</font>|dtm提供类似rocketmq的事务消息|
|
||||||
|通信协议|HTTP|dubbo等协议,无HTTP|dtm后续将支持grpc类协议|
|
|通信协议|HTTP|dubbo等协议,无HTTP|dtm后续将支持grpc类协议|
|
||||||
@ -55,14 +68,15 @@ DTM是首款golang的开源分布式事务管理器,优雅的解决了幂等
|
|||||||
``` GO
|
``` GO
|
||||||
// 具体业务微服务地址
|
// 具体业务微服务地址
|
||||||
const qsBusi = "http://localhost:8081/api/busi_saga"
|
const qsBusi = "http://localhost:8081/api/busi_saga"
|
||||||
req := &gin.H{"amount": 30} // 微服务的载荷
|
req := &gin.H{"amount": 30} // 微服务的载荷
|
||||||
// DtmServer为DTM服务的地址,是一个url
|
// DtmServer为DTM服务的地址,是一个url
|
||||||
saga := dtmcli.NewSaga("http://localhost:8080/api/dtmsvr").
|
DtmServer := "http://localhost:8080/api/dtmsvr"
|
||||||
// 添加一个TransOut的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransOutCompensate"
|
saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
|
||||||
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
|
// 添加一个TransOut的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransOutCompensate"
|
||||||
// 添加一个TransIn的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransInCompensate"
|
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
|
||||||
Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
|
// 添加一个TransIn的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransInCompensate"
|
||||||
// 提交saga事务,dtm会完成所有的子事务/回滚所有的子事务
|
Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
|
||||||
|
// 提交saga事务,dtm会完成所有的子事务/回滚所有的子事务
|
||||||
err := saga.Submit()
|
err := saga.Submit()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ require (
|
|||||||
github.com/gin-gonic/gin v1.6.3
|
github.com/gin-gonic/gin v1.6.3
|
||||||
github.com/go-playground/assert/v2 v2.0.1
|
github.com/go-playground/assert/v2 v2.0.1
|
||||||
github.com/go-resty/resty/v2 v2.6.0
|
github.com/go-resty/resty/v2 v2.6.0
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10 // indirect
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
github.com/kr/pretty v0.1.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||||
|
|||||||
3
go.sum
3
go.sum
@ -91,8 +91,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
|||||||
gorm.io/driver/mysql v1.0.3 h1:+JKBYPfn1tygR1/of/Fh2T8iwuVwzt+PEJmKaXzMQXg=
|
gorm.io/driver/mysql v1.0.3 h1:+JKBYPfn1tygR1/of/Fh2T8iwuVwzt+PEJmKaXzMQXg=
|
||||||
gorm.io/driver/mysql v1.0.3/go.mod h1:twGxftLBlFgNVNakL7F+P/x9oYqoymG3YYT8cAfI9oI=
|
gorm.io/driver/mysql v1.0.3/go.mod h1:twGxftLBlFgNVNakL7F+P/x9oYqoymG3YYT8cAfI9oI=
|
||||||
gorm.io/gorm v1.20.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
gorm.io/gorm v1.20.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
||||||
gorm.io/gorm v1.20.12 h1:ebZ5KrSHzet+sqOCVdH9mTjW91L298nX3v5lVxAzSUY=
|
|
||||||
gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
|
||||||
gorm.io/gorm v1.21.12 h1:3fQM0Eiz7jcJEhPggHEpoYnsGZqynMzverL77DV40RM=
|
gorm.io/gorm v1.21.12 h1:3fQM0Eiz7jcJEhPggHEpoYnsGZqynMzverL77DV40RM=
|
||||||
gorm.io/gorm v1.21.12/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
|
gorm.io/gorm v1.21.12/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user