🔥A cross-language distributed transaction manager. Support xa, tcc, saga, transactional messages. 跨语言分布式事务管理器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.1 KiB

/*
* Copyright (c) 2021 yedf. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
package dtmcli
import (
"fmt"
"github.com/yedf/dtm/dtmcli/dtmimp"
)
// MustGenGid generate a new gid
func MustGenGid(server string) string {
res := map[string]string{}
resp, err := dtmimp.RestyClient.R().SetResult(&res).Get(server + "/newGid")
if err != nil || res["gid"] == "" {
panic(fmt.Errorf("newGid error: %v, resp: %s", err, resp))
}
return res["gid"]
}
// DB interface
type DB = dtmimp.DB
// Tx interface
type Tx = dtmimp.Tx
// TransOptions transaction option
type TransOptions = dtmimp.TransOptions
// SetCurrentDBType set currentDBType
func SetCurrentDBType(dbType string) {
dtmimp.SetCurrentDBType(dbType)
}
// GetCurrentDBType get currentDBType
func GetCurrentDBType() string {
return dtmimp.GetCurrentDBType()
}
// SetXaSqlTimeoutMs set XaSqlTimeoutMs
func XaSqlTimeoutMs(ms int) {
dtmimp.XaSqlTimeoutMs = ms
}
// GetXaSqlTimeoutMs get XaSqlTimeoutMs
func GetXaSqlTimeoutMs() int {
return dtmimp.XaSqlTimeoutMs
}