GitHub - CECTC/hptx: high-performance non-intrusive distributed transaction solu...
source link: https://github.com/cectc/hptx
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
High-performance non-intrusive distributed transaction solution, inspired by kubernetes, only for golang language.
Features
- Event driven, High-performance and non-intrusive
- Support AT mode And TCC mode
- Support check global lock in local transaction
Theory
The distributed transaction principle of hptx and dbpack is the same. For details, please refer to: https://cectc.github.io/dbpack-doc/#/en-us/distributed_transaction
Requirements
- Go 1.16 or higher.
- ETCD(3+)
- AT mode: Mysql (5.7+), MariaDB
Installation
Simple install the package to your $GOPATH with the go tool from shell:
$ go get -u github.com/cectc/hptx
If you use AT mode to solve distributed transaction problems, you should also install the following package:
$ go get -u github.com/cectc/mysql
Make sure Git is installed on your machine and in your system's PATH.
Usage
You should have your ETCD ready first. then, you can initialize hptx via hptx.InitFromFile
:
import (
"github.com/cectc/hptx"
"github.com/cectc/hptx/pkg/config"
"github.com/cectc/hptx/pkg/resource"
"github.com/cectc/mysql"
)
//...
hptx.InitFromFile("${path of your config file}")
// If you use at mode, initial with following code
mysql.RegisterResource(config.GetATConfig().DSN)
resource.InitATBranchResource(mysql.GetDataSourceManager())
It is also possible to set the configuration directly:
import (
"github.com/cectc/hptx"
"github.com/cectc/hptx/pkg/config"
"github.com/cectc/hptx/pkg/resource"
"github.com/cectc/mysql"
)
//...
// Fill in the fields as needed.
hptx.InitWithConf(&config.DistributedTransaction{
ApplicationID: "",
RetryDeadThreshold: 0,
RollbackRetryTimeoutUnlockEnable: false,
EtcdConfig: clientv3.Config{},
ATConfig: config.ATConfig{},
TMConfig: config.TMConfig{},
})
// If you use at mode, initial with following code
mysql.RegisterResource(config.GetATConfig().DSN)
resource.InitATBranchResource(mysql.GetDataSourceManager())
Support GlobalLock:
db.ExecContext(context.WithValue(context.Background(), "GlobalLock", true), sql, args...)
Examples are available in our repos
License
hptx is licensed under the GNU General Public License v3.0.
Recommend
-
67
README.md FESCAR: Fast & Easy Commit And Rollback
-
53
README.md
-
9
README.md
-
9
A non-intrusive support bubble that can be displayed on any page Using this package you can quickly add a chat bubble that opens a support form on any page. It comes with batteries included: TailwindCSS styling out of the...
-
9
English Docs 跨语言分布式事务管理器 DTM是一款变革性的分布式事务框架,提供了傻瓜式的使用方式,极大的降低了分布式事务的使用门槛,改变了“能不用分布式事务就不用”的行业现状。 dtm 的应用范围非常广...
-
8
English | 中文 Introduction dtm/dtm-client is the PHP client of Distributed Transaction M...
-
10
CECTC/dbpack: 用Golang编写的分布式事务中间件 DBPack...
-
8
DBPack
-
1
clap The lightweight, non-intrusive Command Line Argument Parser The m...
-
9
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK