dtm/README.md
2021-06-29 19:01:55 +08:00

61 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 轻量级分布式事务管理服务
DTM 是一款跨语言的分布式事务管理方案,在各类微服务架构中,提供高性能和简单易用的分布式事务服务。
## 特色
* 跨语言
+ 可以使用http方式接入服务。适合go、python、php、nodejs、ruby各类语言使用
* 稳定可靠
+ 经过生产环境考验单元测试覆盖率90%以上
* 高性能
+ golang编写代码质量高
* 易部署
+ 仅依赖mysql部署简单
### [分布式事务简介](./intro-xa.md)
### 多种分布式事务协议支持
* TCC: Try-Confirm-Cancel
* SAGA:
* 可靠消息
* XA 需要底层数据库支持XA
### 高可用
基于数据库实现,易集群化,易水平扩展
# 快速开始
### 安装
`go get github.com/yedf/dtm`
### dtm依赖于mysql
配置mysql
`cp conf.sample.yml conf.yml # 修改conf.yml`
### 启动并运行saga示例
`go run app/main.go`
# 开始使用
### 使用
``` go
const DtmServer = "http://localhost:8080/api/dtmsvr"
const startBusi = "http://localhost:8081/api/busi_saga"
gid := common.GenGid() // 生成事务id
req := &gin.H{"amount": 30} // 微服务的负荷
// 生成dtm的saga对象
saga := dtm.SagaNew(DtmServer, gid).
// 添加两个子事务
Add(startBusi+"/TransOut", startBusi+"/TransOutCompensate", req).
Add(startBusi+"/TransIn", startBusi+"/TransInCompensate", req)
// 提交saga事务
err := saga.Commit()
```
### 完整示例
参考[examples/quick_start.go](./examples/quick_start.go)
### 交流群
请加 yedf2008 好友或者扫码加好友,验证回复 dtm 按照指引进群
![yedf2008](http://service.ivydad.com/cover/dubbingd9af238e-a2a7-e9fa-1267-cc757c83e834.jpeg)
### 谁在使用
<div style='vertical-align: middle'>
<img alt='Alibaba Group' height='40' src='https://www.ivydad.com/_nuxt/img/header-logo.2645ad5.png' /img>
</div>