Skip to content
/ hptx Public

high-performance non-intrusive distributed transaction solution, inspired by kubernetes, only for golang language.

License

Notifications You must be signed in to change notification settings

CECTC/hptx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hptx

LICENSE GitHub Workflow Status GoDoc Go Report Card GitHub Release

High-performance non-intrusive distributed transaction solution, inspired by kubernetes, only for golang language.


Features

  • Event driven, High-performance and non-intrusive
  • Support XA mode、EAT 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.RegisterATResource(config.GetATConfig().DSN)

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.RegisterATResource(config.GetATConfig().DSN)

Support GlobalLock:

db.ExecContext(context.WithValue(context.Background(), "GlobalLock", true), sql, args...)

Examples are available in our repos

Stargazers

Stargazers repo roster for cectc/hptx

License

hptx is licensed under the GNU General Public License v3.0.