seata-golang
Introduction | 中文
seata-golang is a distributed transaction middleware based on Golang.
difference between seata-glang and seata
feature |
seata |
seata-golang |
remark |
AT mode |
√ |
√ |
|
TCC mode |
√ |
√ |
|
SAGA mode |
√ |
× |
|
rpc |
√ |
√ |
dev branch |
grpc |
× |
√ |
v2 branch |
Architecture
A typical lifecycle of Seata managed distributed transaction:
- TM asks TC to begin a new global transaction. TC generates an XID representing the global transaction.
- XID is propagated through microservices' invoke chain.
- RM registers local transaction as a branch of the corresponding global transaction of XID to TC.
- TM asks TC for committing or rolling back the corresponding global transaction of XID.
- TC drives all branch transactions under the corresponding global transaction of XID to finish branch committing or rolling back.
Directory structure
- cmd: to startup TC server
- profiles/dev/config.yml: TC config file
- tc/main.go: TC startup entrance
- dist: to build in docker container
- docs: documentations
- pkg: TC + RM + TM implementation
- server/db/*.sql: sql scripts to create DB and tables for TC
Getting started
cd ${projectpath}/cmd/tc
go build -o tc_server
# create database `seata` for TC server
# update storage.dsn.mysql in ${projectpath}/cmd/profiles/dev/config.yml
./tc_server start -config ${projectpath}/cmd/profiles/dev/config.yml
Please refer to demo seata-go-samples
-
Prerequisites
- MySQL server
- Golang version >= 1.15
- Business tables that require primary key
Design and implementation
The seata-golang AT and TCC design are actually the same as seata.
Please refer to what-is-seata for more details.
Reference
Please contact us via DingTalk app if you have any issues. The chat group ID is 33069364.
Contributing
Welcome to raise up issue or pull-request to seata-golang!
To contribute, fork from opentrx/seata-golang and push branch to your repo, then open a pull-request.
License
seata-golang software is licenced under the Apache License Version 2.0. See the LICENSE file for details.