dtm/README.md
2021-06-04 19:28:37 +08:00

30 lines
749 B
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.

## 轻量级分布式事务管理服务
* 跨语言
- 语言无关基于http协议
* 多种协议支持
- 支持xa、tcc、saga
## 运行示例
### dtm依赖于mysql
使用已有的mysql
`cp conf.sample.yml conf.yml # 修改conf.yml`
或者通过docker安装mysql
`docker-compose up -f compose.mysql.yml`
### 启动并运行saga示例
`go run app/main.go`
## 开始使用
### 安装
`go get github.com/yedf/dtm`
### 使用
``` go
gid := common.GenGid()
req := &gin.H{"amount": 30}
saga := dtm.SagaNew(DtmServer, gid).
Add(startBusi+"/TransOut", startBusi+"/TransOutCompensate", req).
Add(startBusi+"/TransIn", startBusi+"/TransInCompensate", req)
err := saga.Commit()
```
### 完整示例
参考examples/quick_start.go