Browse Source

Merge pull request #330 from dtm-labs/alpha

Workflow fully supported
pull/331/head v1.15.1
yedf2 4 years ago
committed by GitHub
parent
commit
1d1f7eb9ad
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      client/README.md
  2. 11
      client/dtmcli/barrier.go
  3. 4
      client/dtmcli/barrier_mongo.go
  4. 4
      client/dtmcli/barrier_redis.go
  5. 2
      client/dtmcli/consts.go
  6. 0
      client/dtmcli/cover_test.go
  7. 0
      client/dtmcli/dtmimp/README-cn.md
  8. 0
      client/dtmcli/dtmimp/README.md
  9. 0
      client/dtmcli/dtmimp/consts.go
  10. 0
      client/dtmcli/dtmimp/db_special.go
  11. 0
      client/dtmcli/dtmimp/db_special_test.go
  12. 3
      client/dtmcli/dtmimp/trans_base.go
  13. 2
      client/dtmcli/dtmimp/trans_xa_base.go
  14. 0
      client/dtmcli/dtmimp/types.go
  15. 0
      client/dtmcli/dtmimp/types_test.go
  16. 26
      client/dtmcli/dtmimp/utils.go
  17. 0
      client/dtmcli/dtmimp/utils_test.go
  18. 5
      client/dtmcli/dtmimp/vars.go
  19. 0
      client/dtmcli/logger/log.go
  20. 7
      client/dtmcli/logger/logger_test.go
  21. 4
      client/dtmcli/trans_msg.go
  22. 2
      client/dtmcli/trans_saga.go
  23. 4
      client/dtmcli/trans_tcc.go
  24. 12
      client/dtmcli/types.go
  25. 4
      client/dtmcli/types_test.go
  26. 74
      client/dtmcli/utils.go
  27. 4
      client/dtmcli/xa.go
  28. 4
      client/dtmgrpc/barrier.go
  29. 0
      client/dtmgrpc/dtmgimp/README-cn.md
  30. 0
      client/dtmgrpc/dtmgimp/README.md
  31. 6
      client/dtmgrpc/dtmgimp/grpc_clients.go
  32. 4
      client/dtmgrpc/dtmgimp/types.go
  33. 6
      client/dtmgrpc/dtmgimp/utils.go
  34. 831
      client/dtmgrpc/dtmgpb/dtmgimp.pb.go
  35. 9
      client/dtmgrpc/dtmgpb/dtmgimp.proto
  36. 4
      client/dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go
  37. 6
      client/dtmgrpc/msg.go
  38. 4
      client/dtmgrpc/saga.go
  39. 6
      client/dtmgrpc/tcc.go
  40. 11
      client/dtmgrpc/type.go
  41. 0
      client/dtmgrpc/type_test.go
  42. 8
      client/dtmgrpc/xa.go
  43. 0
      client/workflow/dummyReadCloser.go
  44. 2
      client/workflow/factory.go
  45. 14
      client/workflow/imp.go
  46. 25
      client/workflow/rpc.go
  47. 8
      client/workflow/server.go
  48. 17
      client/workflow/utils.go
  49. 152
      client/workflow/wfpb/wf.pb.go
  50. 0
      client/workflow/wfpb/wf.proto
  51. 4
      client/workflow/wfpb/wf_grpc.pb.go
  52. 10
      client/workflow/workflow.go
  53. 2
      client/workflow/workflow_test.go
  54. 1
      conf.sample.yml
  55. 62
      dtmcli/utils.go
  56. 736
      dtmgrpc/dtmgpb/dtmgimp.pb.go
  57. 153
      dtmgrpc/workflow/wfpb/wf.pb.go
  58. 35
      dtmsvr/api.go
  59. 13
      dtmsvr/api_grpc.go
  60. 8
      dtmsvr/api_http.go
  61. 6
      dtmsvr/api_json_rpc.go
  62. 5
      dtmsvr/config/config.go
  63. 2
      dtmsvr/config/config_utils.go
  64. 6
      dtmsvr/cron.go
  65. 7
      dtmsvr/entry/main.go
  66. 4
      dtmsvr/storage/boltdb/boltdb.go
  67. 2
      dtmsvr/storage/boltdb/boltdb_test.go
  68. 4
      dtmsvr/storage/redis/redis.go
  69. 2
      dtmsvr/storage/registry/registry.go
  70. 4
      dtmsvr/storage/sql/sql.go
  71. 4
      dtmsvr/storage/trans.go
  72. 47
      dtmsvr/svr.go
  73. 10
      dtmsvr/trans_class.go
  74. 8
      dtmsvr/trans_process.go
  75. 16
      dtmsvr/trans_status.go
  76. 6
      dtmsvr/trans_type_msg.go
  77. 6
      dtmsvr/trans_type_saga.go
  78. 6
      dtmsvr/trans_type_tcc.go
  79. 13
      dtmsvr/trans_type_workflow.go
  80. 4
      dtmsvr/trans_type_xa.go
  81. 3
      dtmsvr/utils.go
  82. 6
      dtmutil/db.go
  83. 6
      dtmutil/utils.go
  84. 1
      go.sum
  85. 4
      helper/bench/main.go
  86. 6
      helper/bench/svr/http.go
  87. 36
      helper/sync-client.sh
  88. 57
      helper/sync-dtmcli.sh
  89. 12
      helper/test-cover.sh
  90. 2
      main.go
  91. 2
      test/api_test.go
  92. 6
      test/base_test.go
  93. 7
      test/busi/barrier.go
  94. 34
      test/busi/base_grpc.go
  95. 10
      test/busi/base_http.go
  96. 4
      test/busi/base_jrpc.go
  97. 6
      test/busi/base_types.go
  98. 8
      test/busi/data.go
  99. 2
      test/busi/quick_start.go
  100. 20
      test/busi/utils.go

31
client/README.md

@ -0,0 +1,31 @@
# Go Client for DTM
There are there packages:
## workflow
Workflow is a new client for DTM. It support the mixed usage of patterns saga, tcc, xa. And it also support the mixed usage of http, grpc and local transactions.
This pattern offers maximum flexibility and can handle a wide range of scenarios. This pattern is highly recommended for transactions that need to be rolled back
Quick start for workflow using http can be found here: [https://github.com/dtm-labs/quick-start-sample/tree/main/workflow-http](https://github.com/dtm-labs/quick-start-sample/tree/main/workflow-http)
Quick start for workflow using grpc can be found here: [https://github.com/dtm-labs/quick-start-sample/tree/main/workflow-grpc](https://github.com/dtm-labs/quick-start-sample/tree/main/workflow-grpc)
Detailed examples can be found here: [https://github.com/dtm-labs/dtm-examples](https://github.com/dtm-labs/dtm-examples)
## dtmcli
dtmcli is the http client for patterns: saga, tcc, msg, xa
Quick start for dtmcli can be found here: [https://github.com/dtm-labs/quick-start-sample/tree/main/dtmcli-qs](https://github.com/dtm-labs/quick-start-sample/tree/main/dtmcli-qs)
Detailed examples can be found here: [https://github.com/dtm-labs/dtm-examples](https://github.com/dtm-labs/dtm-examples)
## dtmgrpc
dtmcli is the grpc client for patterns: saga, tcc, msg, xa
Quick start for dtmgrpc can be found here: [https://github.com/dtm-labs/quick-start-sample/tree/main/dtmgrpc-qs](https://github.com/dtm-labs/quick-start-sample/tree/main/dtmgrpc-qs)
Detailed examples can be found here: [https://github.com/dtm-labs/dtm-examples](https://github.com/dtm-labs/dtm-examples)

11
dtmcli/barrier.go → client/dtmcli/barrier.go

@ -11,8 +11,8 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
// BarrierBusiFunc type for busi func // BarrierBusiFunc type for busi func
@ -68,8 +68,9 @@ func (bb *BranchBarrier) Call(tx *sql.Tx, busiCall BarrierBusiFunc) (rerr error)
return tx.Rollback() return tx.Rollback()
}) })
originOp := map[string]string{ originOp := map[string]string{
dtmimp.OpCancel: dtmimp.OpTry, dtmimp.OpCancel: dtmimp.OpTry, // tcc
dtmimp.OpCompensate: dtmimp.OpAction, dtmimp.OpCompensate: dtmimp.OpAction, // saga
dtmimp.OpRollback: dtmimp.OpAction, // workflow
}[bb.Op] }[bb.Op]
originAffected, oerr := dtmimp.InsertBarrier(tx, bb.TransType, bb.Gid, bb.BranchID, originOp, bid, bb.Op, bb.DBType, bb.BarrierTableName) originAffected, oerr := dtmimp.InsertBarrier(tx, bb.TransType, bb.Gid, bb.BranchID, originOp, bid, bb.Op, bb.DBType, bb.BarrierTableName)
@ -84,7 +85,7 @@ func (bb *BranchBarrier) Call(tx *sql.Tx, busiCall BarrierBusiFunc) (rerr error)
rerr = oerr rerr = oerr
} }
if (bb.Op == dtmimp.OpCancel || bb.Op == dtmimp.OpCompensate) && originAffected > 0 || // null compensate if (bb.Op == dtmimp.OpCancel || bb.Op == dtmimp.OpCompensate || bb.Op == dtmimp.OpRollback) && originAffected > 0 || // null compensate
currentAffected == 0 { // repeated request or dangled request currentAffected == 0 { // repeated request or dangled request
return return
} }

4
dtmcli/barrier_mongo.go → client/dtmcli/barrier_mongo.go

@ -4,8 +4,8 @@ import (
"context" "context"
"strings" "strings"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
) )

4
dtmcli/barrier_redis.go → client/dtmcli/barrier_redis.go

@ -3,8 +3,8 @@ package dtmcli
import ( import (
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )

2
dtmcli/consts.go → client/dtmcli/consts.go

@ -7,7 +7,7 @@
package dtmcli package dtmcli
import ( import (
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
) )
const ( const (

0
dtmcli/cover_test.go → client/dtmcli/cover_test.go

0
dtmcli/dtmimp/README-cn.md → client/dtmcli/dtmimp/README-cn.md

0
dtmcli/dtmimp/README.md → client/dtmcli/dtmimp/README.md

0
dtmcli/dtmimp/consts.go → client/dtmcli/dtmimp/consts.go

0
dtmcli/dtmimp/db_special.go → client/dtmcli/dtmimp/db_special.go

0
dtmcli/dtmimp/db_special_test.go → client/dtmcli/dtmimp/db_special_test.go

3
dtmcli/dtmimp/trans_base.go → client/dtmcli/dtmimp/trans_base.go

@ -152,9 +152,6 @@ func TransRequestBranch(t *TransBase, method string, body interface{}, branchID
SetQueryParams(query). SetQueryParams(query).
SetHeaders(t.BranchHeaders). SetHeaders(t.BranchHeaders).
Execute(method, url) Execute(method, url)
if err == nil {
err = RespAsErrorCompatible(resp)
}
return resp, err return resp, err
} }

2
dtmcli/dtmimp/trans_xa_base.go → client/dtmcli/dtmimp/trans_xa_base.go

@ -37,7 +37,7 @@ func XaHandleLocalTrans(xa *TransBase, dbConf DBConf, cb func(*sql.DB) error) (r
if rerr != nil { if rerr != nil {
return return
} }
defer func() { _ = db.Close() }() defer XaClose(db)
defer DeferDo(&rerr, func() error { defer DeferDo(&rerr, func() error {
_, err := DBExec(dbConf.Driver, db, GetDBSpecial(dbConf.Driver).GetXaSQL("prepare", xaBranch)) _, err := DBExec(dbConf.Driver, db, GetDBSpecial(dbConf.Driver).GetXaSQL("prepare", xaBranch))
return err return err

0
dtmcli/dtmimp/types.go → client/dtmcli/dtmimp/types.go

0
dtmcli/dtmimp/types_test.go → client/dtmcli/dtmimp/types_test.go

26
dtmcli/dtmimp/utils.go → client/dtmcli/dtmimp/utils.go

@ -11,7 +11,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/http"
"net/url" "net/url"
"os" "os"
"runtime" "runtime"
@ -20,7 +19,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -182,10 +181,16 @@ func XaDB(conf DBConf) (*sql.DB, error) {
if conf.Driver == DBTypeMysql { if conf.Driver == DBTypeMysql {
dsn += "&autocommit=0" dsn += "&autocommit=0"
} }
logger.Infof("opening standalone %s: %s", conf.Driver, strings.Replace(dsn, conf.Password, "****", 1)) logger.Infof("opening xa standalone %s: %s", conf.Driver, strings.Replace(dsn, conf.Password, "****", 1))
return sql.Open(conf.Driver, dsn) return sql.Open(conf.Driver, dsn)
} }
// XaClose will log and close the db
func XaClose(db *sql.DB) {
logger.Infof("closing xa db")
_ = db.Close()
}
// DBExec use raw db to exec // DBExec use raw db to exec
func DBExec(dbType string, db DB, sql string, values ...interface{}) (affected int64, rerr error) { func DBExec(dbType string, db DB, sql string, values ...interface{}) (affected int64, rerr error) {
if sql == "" { if sql == "" {
@ -218,21 +223,6 @@ func GetDsn(conf DBConf) string {
return dsn return dsn
} }
// RespAsErrorCompatible translate a resty response to error
// compatible with version < v1.10
func RespAsErrorCompatible(resp *resty.Response) error {
code := resp.StatusCode()
str := resp.String()
if code == http.StatusTooEarly || strings.Contains(str, ResultOngoing) {
return fmt.Errorf("%s. %w", str, ErrOngoing)
} else if code == http.StatusConflict || strings.Contains(str, ResultFailure) {
return fmt.Errorf("%s. %w", str, ErrFailure)
} else if code != http.StatusOK {
return errors.New(str)
}
return nil
}
// RespAsErrorByJSONRPC translate json rpc resty response to error // RespAsErrorByJSONRPC translate json rpc resty response to error
func RespAsErrorByJSONRPC(resp *resty.Response) error { func RespAsErrorByJSONRPC(resp *resty.Response) error {
str := resp.String() str := resp.String()

0
dtmcli/dtmimp/utils_test.go → client/dtmcli/dtmimp/utils_test.go

5
dtmcli/dtmimp/vars.go → client/dtmcli/dtmimp/vars.go

@ -9,7 +9,7 @@ package dtmimp
import ( import (
"errors" "errors"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtmdriver" "github.com/dtm-labs/dtmdriver"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -24,9 +24,6 @@ var ErrOngoing = errors.New("ONGOING")
// if QueryPrepared executed before call. then DoAndSubmit return this error // if QueryPrepared executed before call. then DoAndSubmit return this error
var ErrDuplicated = errors.New("DUPLICATED") var ErrDuplicated = errors.New("DUPLICATED")
// XaSQLTimeoutMs milliseconds for Xa sql to timeout
var XaSQLTimeoutMs = 15000
// MapSuccess HTTP result of SUCCESS // MapSuccess HTTP result of SUCCESS
var MapSuccess = map[string]interface{}{"dtm_result": ResultSuccess} var MapSuccess = map[string]interface{}{"dtm_result": ResultSuccess}

0
dtmcli/logger/log.go → client/dtmcli/logger/log.go

7
dtmcli/logger/logger_test.go → client/dtmcli/logger/logger_test.go

@ -4,6 +4,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/assert"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -37,3 +38,9 @@ func TestWithLogger(t *testing.T) {
FatalfIf(false, "nothing") FatalfIf(false, "nothing")
FatalIfError(nil) FatalIfError(nil)
} }
func TestCover(t *testing.T) {
sin := lumberjackSink{}
err := sin.Sync()
assert.Nil(t, err)
}

4
dtmcli/trans_msg.go → client/dtmcli/trans_msg.go

@ -10,7 +10,7 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
) )
// Msg reliable msg type // Msg reliable msg type
@ -69,7 +69,7 @@ func (s *Msg) DoAndSubmit(queryPrepared string, busiCall func(bb *BranchBarrier)
errb := busiCall(bb) errb := busiCall(bb)
if errb != nil && !errors.Is(errb, ErrFailure) { if errb != nil && !errors.Is(errb, ErrFailure) {
// if busicall return an error other than failure, we will query the result // if busicall return an error other than failure, we will query the result
_, err = dtmimp.TransRequestBranch(&s.TransBase, "GET", nil, bb.BranchID, bb.Op, queryPrepared) _, err = requestBranch(&s.TransBase, "GET", nil, bb.BranchID, bb.Op, queryPrepared)
} }
if errors.Is(errb, ErrFailure) || errors.Is(err, ErrFailure) { if errors.Is(errb, ErrFailure) || errors.Is(err, ErrFailure) {
_ = dtmimp.TransCallDtm(&s.TransBase, "abort") _ = dtmimp.TransCallDtm(&s.TransBase, "abort")

2
dtmcli/trans_saga.go → client/dtmcli/trans_saga.go

@ -7,7 +7,7 @@
package dtmcli package dtmcli
import ( import (
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
) )
// Saga struct of saga // Saga struct of saga

4
dtmcli/trans_tcc.go → client/dtmcli/trans_tcc.go

@ -10,7 +10,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -71,5 +71,5 @@ func (t *Tcc) CallBranch(body interface{}, tryURL string, confirmURL string, can
if err != nil { if err != nil {
return nil, err return nil, err
} }
return dtmimp.TransRequestBranch(&t.TransBase, "POST", body, branchID, dtmimp.OpTry, tryURL) return requestBranch(&t.TransBase, "POST", body, branchID, dtmimp.OpTry, tryURL)
} }

12
dtmcli/types.go → client/dtmcli/types.go

@ -7,7 +7,7 @@
package dtmcli package dtmcli
import ( import (
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -30,16 +30,6 @@ func GetCurrentDBType() string {
return dtmimp.GetCurrentDBType() return dtmimp.GetCurrentDBType()
} }
// SetXaSQLTimeoutMs set XaSQLTimeoutMs
func SetXaSQLTimeoutMs(ms int) {
dtmimp.XaSQLTimeoutMs = ms
}
// GetXaSQLTimeoutMs get XaSQLTimeoutMs
func GetXaSQLTimeoutMs() int {
return dtmimp.XaSQLTimeoutMs
}
// SetBarrierTableName sets barrier table name // SetBarrierTableName sets barrier table name
func SetBarrierTableName(tablename string) { func SetBarrierTableName(tablename string) {
dtmimp.BarrierTableName = tablename dtmimp.BarrierTableName = tablename

4
dtmcli/types_test.go → client/dtmcli/types_test.go

@ -10,7 +10,7 @@ import (
"net/url" "net/url"
"testing" "testing"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -26,7 +26,5 @@ func TestTypes(t *testing.T) {
} }
func TestXaSqlTimeout(t *testing.T) { func TestXaSqlTimeout(t *testing.T) {
old := GetXaSQLTimeoutMs()
SetXaSQLTimeoutMs(old)
SetBarrierTableName(dtmimp.BarrierTableName) // just cover this func SetBarrierTableName(dtmimp.BarrierTableName) // just cover this func
} }

74
client/dtmcli/utils.go

@ -0,0 +1,74 @@
package dtmcli
import (
"errors"
"fmt"
"net/http"
"strings"
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/go-resty/resty/v2"
)
// 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"]
}
// ErrorMessage2Error return an error fmt.Errorf("%s %w", errMsg, err) but trim out duplicate wrap
// eg. ErrorMessage2Error("an error. FAILURE", ErrFailure) return an error with message: "an error. FAILURE",
// no additional " FAILURE" added
func ErrorMessage2Error(errMsg string, err error) error {
errMsg = strings.TrimSuffix(errMsg, " "+err.Error())
return fmt.Errorf("%s %w", errMsg, err)
}
// HTTPResp2DtmError translate a resty response to error
// compatible with version < v1.10
func HTTPResp2DtmError(resp *resty.Response) error {
code := resp.StatusCode()
str := resp.String()
if code == http.StatusTooEarly || strings.Contains(str, ResultOngoing) {
return ErrorMessage2Error(str, ErrOngoing)
} else if code == http.StatusConflict || strings.Contains(str, ResultFailure) {
return ErrorMessage2Error(str, ErrFailure)
} else if code != http.StatusOK {
return errors.New(str)
}
return nil
}
// Result2HttpJSON return the http code and json result
// if result is error, the return proper code, else return StatusOK
func Result2HttpJSON(result interface{}) (code int, res interface{}) {
err, _ := result.(error)
if err == nil {
code = http.StatusOK
res = result
} else {
res = map[string]string{
"error": err.Error(),
}
if errors.Is(err, ErrFailure) {
code = http.StatusConflict
} else if errors.Is(err, ErrOngoing) {
code = http.StatusTooEarly
} else if err != nil {
code = http.StatusInternalServerError
}
}
return
}
func requestBranch(t *dtmimp.TransBase, method string, body interface{}, branchID string, op string, url string) (*resty.Response, error) {
resp, err := dtmimp.TransRequestBranch(t, method, body, branchID, op, url)
if err == nil {
err = HTTPResp2DtmError(resp)
}
return resp, err
}

4
dtmcli/xa.go → client/dtmcli/xa.go

@ -11,7 +11,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -79,5 +79,5 @@ func XaGlobalTransaction2(server string, gid string, custom func(*Xa), xaFunc Xa
// CallBranch call a xa branch // CallBranch call a xa branch
func (x *Xa) CallBranch(body interface{}, url string) (*resty.Response, error) { func (x *Xa) CallBranch(body interface{}, url string) (*resty.Response, error) {
branchID := x.NewSubBranchID() branchID := x.NewSubBranchID()
return dtmimp.TransRequestBranch(&x.TransBase, "POST", body, branchID, dtmimp.OpAction, url) return requestBranch(&x.TransBase, "POST", body, branchID, dtmimp.OpAction, url)
} }

4
dtmgrpc/barrier.go → client/dtmgrpc/barrier.go

@ -9,8 +9,8 @@ package dtmgrpc
import ( import (
"context" "context"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
) )
// BarrierFromGrpc generate a Barrier from grpc context // BarrierFromGrpc generate a Barrier from grpc context

0
dtmgrpc/dtmgimp/README-cn.md → client/dtmgrpc/dtmgimp/README-cn.md

0
dtmgrpc/dtmgimp/README.md → client/dtmgrpc/dtmgimp/README.md

6
dtmgrpc/dtmgimp/grpc_clients.go → client/dtmgrpc/dtmgimp/grpc_clients.go

@ -10,9 +10,9 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
) )

4
dtmgrpc/dtmgimp/types.go → client/dtmgrpc/dtmgimp/types.go

@ -11,8 +11,8 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtmdriver" "github.com/dtm-labs/dtmdriver"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"

6
dtmgrpc/dtmgimp/utils.go → client/dtmgrpc/dtmgimp/utils.go

@ -9,9 +9,9 @@ package dtmgimp
import ( import (
context "context" context "context"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
emptypb "google.golang.org/protobuf/types/known/emptypb" emptypb "google.golang.org/protobuf/types/known/emptypb"

831
client/dtmgrpc/dtmgpb/dtmgimp.pb.go

@ -0,0 +1,831 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.17.3
// source: client/dtmgrpc/dtmgpb/dtmgimp.proto
package dtmgpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type DtmTransOptions struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
WaitResult bool `protobuf:"varint,1,opt,name=WaitResult,proto3" json:"WaitResult,omitempty"`
TimeoutToFail int64 `protobuf:"varint,2,opt,name=TimeoutToFail,proto3" json:"TimeoutToFail,omitempty"`
RetryInterval int64 `protobuf:"varint,3,opt,name=RetryInterval,proto3" json:"RetryInterval,omitempty"`
PassthroughHeaders []string `protobuf:"bytes,4,rep,name=PassthroughHeaders,proto3" json:"PassthroughHeaders,omitempty"`
BranchHeaders map[string]string `protobuf:"bytes,5,rep,name=BranchHeaders,proto3" json:"BranchHeaders,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
RequestTimeout int64 `protobuf:"varint,6,opt,name=RequestTimeout,proto3" json:"RequestTimeout,omitempty"`
}
func (x *DtmTransOptions) Reset() {
*x = DtmTransOptions{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmTransOptions) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmTransOptions) ProtoMessage() {}
func (x *DtmTransOptions) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmTransOptions.ProtoReflect.Descriptor instead.
func (*DtmTransOptions) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{0}
}
func (x *DtmTransOptions) GetWaitResult() bool {
if x != nil {
return x.WaitResult
}
return false
}
func (x *DtmTransOptions) GetTimeoutToFail() int64 {
if x != nil {
return x.TimeoutToFail
}
return 0
}
func (x *DtmTransOptions) GetRetryInterval() int64 {
if x != nil {
return x.RetryInterval
}
return 0
}
func (x *DtmTransOptions) GetPassthroughHeaders() []string {
if x != nil {
return x.PassthroughHeaders
}
return nil
}
func (x *DtmTransOptions) GetBranchHeaders() map[string]string {
if x != nil {
return x.BranchHeaders
}
return nil
}
func (x *DtmTransOptions) GetRequestTimeout() int64 {
if x != nil {
return x.RequestTimeout
}
return 0
}
// DtmRequest request sent to dtm server
type DtmRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
TransOptions *DtmTransOptions `protobuf:"bytes,3,opt,name=TransOptions,proto3" json:"TransOptions,omitempty"`
CustomedData string `protobuf:"bytes,4,opt,name=CustomedData,proto3" json:"CustomedData,omitempty"`
BinPayloads [][]byte `protobuf:"bytes,5,rep,name=BinPayloads,proto3" json:"BinPayloads,omitempty"` // for Msg/Saga/Workflow branch payloads
QueryPrepared string `protobuf:"bytes,6,opt,name=QueryPrepared,proto3" json:"QueryPrepared,omitempty"` // for Msg
Steps string `protobuf:"bytes,7,opt,name=Steps,proto3" json:"Steps,omitempty"`
ReqExtra map[string]string `protobuf:"bytes,8,rep,name=ReqExtra,proto3" json:"ReqExtra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
RollbackReason string `protobuf:"bytes,9,opt,name=RollbackReason,proto3" json:"RollbackReason,omitempty"`
}
func (x *DtmRequest) Reset() {
*x = DtmRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmRequest) ProtoMessage() {}
func (x *DtmRequest) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmRequest.ProtoReflect.Descriptor instead.
func (*DtmRequest) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{1}
}
func (x *DtmRequest) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmRequest) GetTransType() string {
if x != nil {
return x.TransType
}
return ""
}
func (x *DtmRequest) GetTransOptions() *DtmTransOptions {
if x != nil {
return x.TransOptions
}
return nil
}
func (x *DtmRequest) GetCustomedData() string {
if x != nil {
return x.CustomedData
}
return ""
}
func (x *DtmRequest) GetBinPayloads() [][]byte {
if x != nil {
return x.BinPayloads
}
return nil
}
func (x *DtmRequest) GetQueryPrepared() string {
if x != nil {
return x.QueryPrepared
}
return ""
}
func (x *DtmRequest) GetSteps() string {
if x != nil {
return x.Steps
}
return ""
}
func (x *DtmRequest) GetReqExtra() map[string]string {
if x != nil {
return x.ReqExtra
}
return nil
}
func (x *DtmRequest) GetRollbackReason() string {
if x != nil {
return x.RollbackReason
}
return ""
}
type DtmGidReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
}
func (x *DtmGidReply) Reset() {
*x = DtmGidReply{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmGidReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmGidReply) ProtoMessage() {}
func (x *DtmGidReply) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmGidReply.ProtoReflect.Descriptor instead.
func (*DtmGidReply) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{2}
}
func (x *DtmGidReply) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
type DtmBranchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
Op string `protobuf:"bytes,4,opt,name=Op,proto3" json:"Op,omitempty"`
Data map[string]string `protobuf:"bytes,5,rep,name=Data,proto3" json:"Data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
BusiPayload []byte `protobuf:"bytes,6,opt,name=BusiPayload,proto3" json:"BusiPayload,omitempty"`
}
func (x *DtmBranchRequest) Reset() {
*x = DtmBranchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmBranchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmBranchRequest) ProtoMessage() {}
func (x *DtmBranchRequest) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmBranchRequest.ProtoReflect.Descriptor instead.
func (*DtmBranchRequest) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{3}
}
func (x *DtmBranchRequest) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmBranchRequest) GetTransType() string {
if x != nil {
return x.TransType
}
return ""
}
func (x *DtmBranchRequest) GetBranchID() string {
if x != nil {
return x.BranchID
}
return ""
}
func (x *DtmBranchRequest) GetOp() string {
if x != nil {
return x.Op
}
return ""
}
func (x *DtmBranchRequest) GetData() map[string]string {
if x != nil {
return x.Data
}
return nil
}
func (x *DtmBranchRequest) GetBusiPayload() []byte {
if x != nil {
return x.BusiPayload
}
return nil
}
type DtmProgressesReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Transaction *DtmTransaction `protobuf:"bytes,1,opt,name=Transaction,proto3" json:"Transaction,omitempty"`
Progresses []*DtmProgress `protobuf:"bytes,2,rep,name=Progresses,proto3" json:"Progresses,omitempty"`
}
func (x *DtmProgressesReply) Reset() {
*x = DtmProgressesReply{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmProgressesReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmProgressesReply) ProtoMessage() {}
func (x *DtmProgressesReply) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmProgressesReply.ProtoReflect.Descriptor instead.
func (*DtmProgressesReply) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{4}
}
func (x *DtmProgressesReply) GetTransaction() *DtmTransaction {
if x != nil {
return x.Transaction
}
return nil
}
func (x *DtmProgressesReply) GetProgresses() []*DtmProgress {
if x != nil {
return x.Progresses
}
return nil
}
type DtmTransaction struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
Status string `protobuf:"bytes,2,opt,name=Status,proto3" json:"Status,omitempty"`
RollbackReason string `protobuf:"bytes,3,opt,name=RollbackReason,proto3" json:"RollbackReason,omitempty"`
}
func (x *DtmTransaction) Reset() {
*x = DtmTransaction{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmTransaction) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmTransaction) ProtoMessage() {}
func (x *DtmTransaction) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmTransaction.ProtoReflect.Descriptor instead.
func (*DtmTransaction) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{5}
}
func (x *DtmTransaction) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmTransaction) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *DtmTransaction) GetRollbackReason() string {
if x != nil {
return x.RollbackReason
}
return ""
}
type DtmProgress struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Status string `protobuf:"bytes,1,opt,name=Status,proto3" json:"Status,omitempty"`
BinData []byte `protobuf:"bytes,2,opt,name=BinData,proto3" json:"BinData,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
Op string `protobuf:"bytes,4,opt,name=Op,proto3" json:"Op,omitempty"`
}
func (x *DtmProgress) Reset() {
*x = DtmProgress{}
if protoimpl.UnsafeEnabled {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmProgress) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmProgress) ProtoMessage() {}
func (x *DtmProgress) ProtoReflect() protoreflect.Message {
mi := &file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmProgress.ProtoReflect.Descriptor instead.
func (*DtmProgress) Descriptor() ([]byte, []int) {
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{6}
}
func (x *DtmProgress) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *DtmProgress) GetBinData() []byte {
if x != nil {
return x.BinData
}
return nil
}
func (x *DtmProgress) GetBranchID() string {
if x != nil {
return x.BranchID
}
return ""
}
func (x *DtmProgress) GetOp() string {
if x != nil {
return x.Op
}
return ""
}
var File_client_dtmgrpc_dtmgpb_dtmgimp_proto protoreflect.FileDescriptor
var file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = []byte{
0x0a, 0x23, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63,
0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70, 0x62, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x1a, 0x1b,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xea, 0x02, 0x0a, 0x0f,
0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12,
0x1e, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
0x24, 0x0a, 0x0d, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54,
0x6f, 0x46, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e,
0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x52, 0x65,
0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2e, 0x0a, 0x12, 0x50,
0x61, 0x73, 0x73, 0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x50, 0x61, 0x73, 0x73, 0x74, 0x68, 0x72,
0x6f, 0x75, 0x67, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x51, 0x0a, 0x0d, 0x42,
0x72, 0x61, 0x6e, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x42, 0x72, 0x61,
0x6e, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
0x0d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x26,
0x0a, 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54,
0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x40, 0x0a, 0x12, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa0, 0x03, 0x0a, 0x0a, 0x44, 0x74, 0x6d,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x72, 0x61,
0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3c, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e,
0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65,
0x64, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x75, 0x73,
0x74, 0x6f, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x69, 0x6e,
0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b,
0x42, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x51,
0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65,
0x64, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x74, 0x65, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x53, 0x74, 0x65, 0x70, 0x73, 0x12, 0x3d, 0x0a, 0x08, 0x52, 0x65, 0x71, 0x45, 0x78,
0x74, 0x72, 0x61, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x74, 0x6d, 0x67,
0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x52,
0x65, 0x71, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x52, 0x65,
0x71, 0x45, 0x78, 0x74, 0x72, 0x61, 0x12, 0x26, 0x0a, 0x0e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61,
0x63, 0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e,
0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x1a, 0x3b,
0x0a, 0x0d, 0x52, 0x65, 0x71, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x1f, 0x0a, 0x0b, 0x44,
0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x22, 0x82, 0x02, 0x0a,
0x10, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70,
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a,
0x02, 0x4f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x4f, 0x70, 0x12, 0x37, 0x0a,
0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x74,
0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61,
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x75, 0x73,
0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
0x01, 0x22, 0x85, 0x01, 0x0a, 0x12, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73,
0x73, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x39, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e,
0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65,
0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d,
0x70, 0x2e, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0a, 0x50,
0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x62, 0x0a, 0x0e, 0x44, 0x74, 0x6d,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x47,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63,
0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x52,
0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x6b, 0x0a,
0x0b, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x42, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x42, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a,
0x0a, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x4f, 0x70,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x4f, 0x70, 0x32, 0xf8, 0x02, 0x0a, 0x03, 0x44,
0x74, 0x6d, 0x12, 0x38, 0x0a, 0x06, 0x4e, 0x65, 0x77, 0x47, 0x69, 0x64, 0x12, 0x16, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45,
0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44,
0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06,
0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70,
0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x07, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65,
0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12,
0x36, 0x0a, 0x05, 0x41, 0x62, 0x6f, 0x72, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69,
0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x19, 0x2e, 0x64, 0x74, 0x6d, 0x67,
0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x45,
0x0a, 0x0f, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f,
0x77, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70,
0x2e, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce sync.Once
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc
)
func file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP() []byte {
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce.Do(func() {
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData)
})
return file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData
}
var file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_client_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = []interface{}{
(*DtmTransOptions)(nil), // 0: dtmgimp.DtmTransOptions
(*DtmRequest)(nil), // 1: dtmgimp.DtmRequest
(*DtmGidReply)(nil), // 2: dtmgimp.DtmGidReply
(*DtmBranchRequest)(nil), // 3: dtmgimp.DtmBranchRequest
(*DtmProgressesReply)(nil), // 4: dtmgimp.DtmProgressesReply
(*DtmTransaction)(nil), // 5: dtmgimp.DtmTransaction
(*DtmProgress)(nil), // 6: dtmgimp.DtmProgress
nil, // 7: dtmgimp.DtmTransOptions.BranchHeadersEntry
nil, // 8: dtmgimp.DtmRequest.ReqExtraEntry
nil, // 9: dtmgimp.DtmBranchRequest.DataEntry
(*emptypb.Empty)(nil), // 10: google.protobuf.Empty
}
var file_client_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = []int32{
7, // 0: dtmgimp.DtmTransOptions.BranchHeaders:type_name -> dtmgimp.DtmTransOptions.BranchHeadersEntry
0, // 1: dtmgimp.DtmRequest.TransOptions:type_name -> dtmgimp.DtmTransOptions
8, // 2: dtmgimp.DtmRequest.ReqExtra:type_name -> dtmgimp.DtmRequest.ReqExtraEntry
9, // 3: dtmgimp.DtmBranchRequest.Data:type_name -> dtmgimp.DtmBranchRequest.DataEntry
5, // 4: dtmgimp.DtmProgressesReply.Transaction:type_name -> dtmgimp.DtmTransaction
6, // 5: dtmgimp.DtmProgressesReply.Progresses:type_name -> dtmgimp.DtmProgress
10, // 6: dtmgimp.Dtm.NewGid:input_type -> google.protobuf.Empty
1, // 7: dtmgimp.Dtm.Submit:input_type -> dtmgimp.DtmRequest
1, // 8: dtmgimp.Dtm.Prepare:input_type -> dtmgimp.DtmRequest
1, // 9: dtmgimp.Dtm.Abort:input_type -> dtmgimp.DtmRequest
3, // 10: dtmgimp.Dtm.RegisterBranch:input_type -> dtmgimp.DtmBranchRequest
1, // 11: dtmgimp.Dtm.PrepareWorkflow:input_type -> dtmgimp.DtmRequest
2, // 12: dtmgimp.Dtm.NewGid:output_type -> dtmgimp.DtmGidReply
10, // 13: dtmgimp.Dtm.Submit:output_type -> google.protobuf.Empty
10, // 14: dtmgimp.Dtm.Prepare:output_type -> google.protobuf.Empty
10, // 15: dtmgimp.Dtm.Abort:output_type -> google.protobuf.Empty
10, // 16: dtmgimp.Dtm.RegisterBranch:output_type -> google.protobuf.Empty
4, // 17: dtmgimp.Dtm.PrepareWorkflow:output_type -> dtmgimp.DtmProgressesReply
12, // [12:18] is the sub-list for method output_type
6, // [6:12] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_client_dtmgrpc_dtmgpb_dtmgimp_proto_init() }
func file_client_dtmgrpc_dtmgpb_dtmgimp_proto_init() {
if File_client_dtmgrpc_dtmgpb_dtmgimp_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmTransOptions); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmGidReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmBranchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmProgressesReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmTransaction); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmProgress); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_client_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes,
DependencyIndexes: file_client_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs,
MessageInfos: file_client_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes,
}.Build()
File_client_dtmgrpc_dtmgpb_dtmgimp_proto = out.File
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = nil
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = nil
file_client_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = nil
}

9
dtmgrpc/dtmgpb/dtmgimp.proto → client/dtmgrpc/dtmgpb/dtmgimp.proto

@ -51,7 +51,14 @@ message DtmBranchRequest {
} }
message DtmProgressesReply { message DtmProgressesReply {
repeated DtmProgress Progresses = 1; DtmTransaction Transaction = 1;
repeated DtmProgress Progresses = 2;
}
message DtmTransaction {
string Gid = 1;
string Status = 2;
string RollbackReason = 3;
} }
message DtmProgress { message DtmProgress {

4
dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go → client/dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go

@ -2,7 +2,7 @@
// versions: // versions:
// - protoc-gen-go-grpc v1.2.0 // - protoc-gen-go-grpc v1.2.0
// - protoc v3.17.3 // - protoc v3.17.3
// source: dtmgrpc/dtmgpb/dtmgimp.proto // source: client/dtmgrpc/dtmgpb/dtmgimp.proto
package dtmgpb package dtmgpb
@ -282,5 +282,5 @@ var Dtm_ServiceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "dtmgrpc/dtmgpb/dtmgimp.proto", Metadata: "client/dtmgrpc/dtmgpb/dtmgimp.proto",
} }

6
dtmgrpc/msg.go → client/dtmgrpc/msg.go

@ -10,9 +10,9 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )

4
dtmgrpc/saga.go → client/dtmgrpc/saga.go

@ -7,8 +7,8 @@
package dtmgrpc package dtmgrpc
import ( import (
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )

6
dtmgrpc/tcc.go → client/dtmgrpc/tcc.go

@ -10,9 +10,9 @@ import (
context "context" context "context"
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )

11
dtmgrpc/type.go → client/dtmgrpc/type.go

@ -9,11 +9,10 @@ package dtmgrpc
import ( import (
context "context" context "context"
"errors" "errors"
"fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtmdriver" "github.com/dtm-labs/dtmdriver"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
@ -40,9 +39,9 @@ func GrpcError2DtmError(err error) error {
if st.Message() == dtmcli.ResultOngoing { if st.Message() == dtmcli.ResultOngoing {
return dtmcli.ErrOngoing return dtmcli.ErrOngoing
} }
return fmt.Errorf("%s. %w", st.Message(), dtmcli.ErrFailure) return dtmcli.ErrorMessage2Error(st.Message(), dtmcli.ErrFailure)
} else if st != nil && st.Code() == codes.FailedPrecondition { } else if st != nil && st.Code() == codes.FailedPrecondition {
return fmt.Errorf("%s. %w", st.Message(), dtmcli.ErrOngoing) return dtmcli.ErrorMessage2Error(st.Message(), dtmcli.ErrOngoing)
} }
return err return err
} }

0
dtmgrpc/type_test.go → client/dtmgrpc/type_test.go

8
dtmgrpc/xa.go → client/dtmgrpc/xa.go

@ -11,10 +11,10 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
emptypb "google.golang.org/protobuf/types/known/emptypb" emptypb "google.golang.org/protobuf/types/known/emptypb"

0
dtmgrpc/workflow/dummyReadCloser.go → client/workflow/dummyReadCloser.go

2
dtmgrpc/workflow/factory.go → client/workflow/factory.go

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
type workflowFactory struct { type workflowFactory struct {

14
dtmgrpc/workflow/imp.go → client/workflow/imp.go

@ -5,9 +5,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@ -39,7 +39,7 @@ func (wf *Workflow) loadProgresses() error {
Data: p.BinData, Data: p.BinData,
} }
if sr.Status == dtmcli.StatusFailed { if sr.Status == dtmcli.StatusFailed {
sr.Error = fmt.Errorf("%s. %w", string(p.BinData), dtmcli.ErrFailure) sr.Error = dtmcli.ErrorMessage2Error(string(p.BinData), dtmcli.ErrFailure)
} }
wf.progresses[p.BranchID+"-"+p.Op] = sr wf.progresses[p.BranchID+"-"+p.Op] = sr
} }
@ -86,7 +86,7 @@ func (wf *Workflow) initRestyClient() {
"gid": wf.Gid, "gid": wf.Gid,
"trans_type": wf.TransType, "trans_type": wf.TransType,
"branch_id": wf.currentBranch, "branch_id": wf.currentBranch,
"op": dtmimp.OpAction, "op": wf.currentOp,
}) })
err := dtmimp.BeforeRequest(c, r) err := dtmimp.BeforeRequest(c, r)
return err return err
@ -109,7 +109,7 @@ func (wf *Workflow) process(handler WfFunc, data []byte) (err error) {
err = wf.processPhase2(err) err = wf.processPhase2(err)
} }
if err == nil || errors.Is(err, dtmcli.ErrFailure) { if err == nil || errors.Is(err, dtmcli.ErrFailure) {
err1 := wf.submit(wfErrorToStatus(err)) err1 := wf.submit(err)
if err1 != nil { if err1 != nil {
return err1 return err1
} }
@ -178,7 +178,7 @@ func (wf *Workflow) recordedDoInner(fn func(bb *dtmcli.BranchBarrier) *stepResul
} }
r := wf.getStepResult() r := wf.getStepResult()
if r != nil { if r != nil {
logger.Debugf("progress restored: %s %s %v %s %s", branchID, wf.currentOp, r.Error, r.Status, r.Data) logger.Debugf("progress restored: '%s' '%s' '%v' '%s' '%s'", branchID, wf.currentOp, r.Error, r.Status, r.Data)
return r return r
} }
bb := &dtmcli.BranchBarrier{ bb := &dtmcli.BranchBarrier{

25
dtmgrpc/workflow/rpc.go → client/workflow/rpc.go

@ -3,9 +3,9 @@ package workflow
import ( import (
"context" "context"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/emptypb"
) )
@ -20,20 +20,26 @@ func (wf *Workflow) getProgress() ([]*dtmgpb.DtmProgress, error) {
return nil, err return nil, err
} }
resp, err := dtmimp.RestyClient.R().SetBody(wf.TransBase).Post(wf.Dtm + "/prepareWorkflow") resp, err := dtmimp.RestyClient.R().SetBody(wf.TransBase).Post(wf.Dtm + "/prepareWorkflow")
var progresses []*dtmgpb.DtmProgress var reply dtmgpb.DtmProgressesReply
if err == nil { if err == nil {
dtmimp.MustUnmarshal(resp.Body(), &progresses) dtmimp.MustUnmarshal(resp.Body(), &reply)
} }
return progresses, err return reply.Progresses, err
} }
func (wf *Workflow) submit(status string) error { func (wf *Workflow) submit(err error) error {
status := wfErrorToStatus(err)
reason := ""
if err != nil {
reason = err.Error()
}
if wf.Protocol == dtmimp.ProtocolHTTP { if wf.Protocol == dtmimp.ProtocolHTTP {
m := map[string]interface{}{ m := map[string]interface{}{
"gid": wf.Gid, "gid": wf.Gid,
"trans_type": wf.TransType, "trans_type": wf.TransType,
"req_extra": map[string]string{ "req_extra": map[string]string{
"status": status, "status": status,
"rollback_reason": reason,
}, },
} }
_, err := dtmimp.TransCallDtmExt(wf.TransBase, m, "submit") _, err := dtmimp.TransCallDtmExt(wf.TransBase, m, "submit")
@ -41,7 +47,8 @@ func (wf *Workflow) submit(status string) error {
} }
req := dtmgimp.GetDtmRequest(wf.TransBase) req := dtmgimp.GetDtmRequest(wf.TransBase)
req.ReqExtra = map[string]string{ req.ReqExtra = map[string]string{
"status": status, "status": status,
"rollback_reason": reason,
} }
reply := emptypb.Empty{} reply := emptypb.Empty{}
return dtmgimp.MustGetGrpcConn(wf.Dtm, false).Invoke(wf.Context, "/dtmgimp.Dtm/"+"Submit", req, &reply) return dtmgimp.MustGetGrpcConn(wf.Dtm, false).Invoke(wf.Context, "/dtmgimp.Dtm/"+"Submit", req, &reply)

8
dtmgrpc/workflow/server.go → client/workflow/server.go

@ -3,10 +3,10 @@ package workflow
import ( import (
"context" "context"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/workflow/wfpb" "github.com/dtm-labs/dtm/client/workflow/wfpb"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/emptypb"

17
dtmgrpc/workflow/utils.go → client/workflow/utils.go

@ -3,14 +3,13 @@ package workflow
import ( import (
"bytes" "bytes"
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strconv" "strconv"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoreflect"
@ -75,9 +74,9 @@ func HTTPResp2DtmError(resp *http.Response) ([]byte, error) {
data, err := ioutil.ReadAll(resp.Body) data, err := ioutil.ReadAll(resp.Body)
resp.Body = ioutil.NopCloser(bytes.NewBuffer(data)) resp.Body = ioutil.NopCloser(bytes.NewBuffer(data))
if code == http.StatusTooEarly { if code == http.StatusTooEarly {
return data, fmt.Errorf("%s. %w", string(data), dtmcli.ErrOngoing) return data, dtmcli.ErrorMessage2Error(string(data), dtmcli.ErrOngoing)
} else if code == http.StatusConflict { } else if code == http.StatusConflict {
return data, fmt.Errorf("%s. %w", string(data), dtmcli.ErrFailure) return data, dtmcli.ErrorMessage2Error(string(data), dtmcli.ErrFailure)
} else if err == nil && code != http.StatusOK { } else if err == nil && code != http.StatusOK {
return data, errors.New(string(data)) return data, errors.New(string(data))
} }
@ -88,9 +87,9 @@ func HTTPResp2DtmError(resp *http.Response) ([]byte, error) {
func GrpcError2DtmError(err error) error { func GrpcError2DtmError(err error) error {
st, _ := status.FromError(err) st, _ := status.FromError(err)
if st != nil && st.Code() == codes.Aborted { if st != nil && st.Code() == codes.Aborted {
return fmt.Errorf("%s. %w", st.Message(), dtmcli.ErrFailure) return dtmcli.ErrorMessage2Error(st.Message(), dtmcli.ErrFailure)
} else if st != nil && st.Code() == codes.FailedPrecondition { } else if st != nil && st.Code() == codes.FailedPrecondition {
return fmt.Errorf("%s. %w", st.Message(), dtmcli.ErrOngoing) return dtmcli.ErrorMessage2Error(st.Message(), dtmcli.ErrOngoing)
} }
return err return err
} }
@ -113,7 +112,7 @@ func (wf *Workflow) stepResultFromGrpc(reply interface{}, err error) *stepResult
if sr.Error == nil { if sr.Error == nil {
sr.Data = dtmgimp.MustProtoMarshal(reply.(protoreflect.ProtoMessage)) sr.Data = dtmgimp.MustProtoMarshal(reply.(protoreflect.ProtoMessage))
} else if sr.Status == dtmcli.StatusFailed { } else if sr.Status == dtmcli.StatusFailed {
sr.Data = []byte(sr.Error.Error()) sr.Data = []byte(err.Error())
} }
return sr return sr
} }

152
client/workflow/wfpb/wf.pb.go

@ -0,0 +1,152 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.17.3
// source: workflow/wfpb/wf.proto
package wfpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type WorkflowData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *WorkflowData) Reset() {
*x = WorkflowData{}
if protoimpl.UnsafeEnabled {
mi := &file_workflow_wfpb_wf_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WorkflowData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WorkflowData) ProtoMessage() {}
func (x *WorkflowData) ProtoReflect() protoreflect.Message {
mi := &file_workflow_wfpb_wf_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use WorkflowData.ProtoReflect.Descriptor instead.
func (*WorkflowData) Descriptor() ([]byte, []int) {
return file_workflow_wfpb_wf_proto_rawDescGZIP(), []int{0}
}
func (x *WorkflowData) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
var File_workflow_wfpb_wf_proto protoreflect.FileDescriptor
var file_workflow_wfpb_wf_proto_rawDesc = []byte{
0x0a, 0x16, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x77, 0x66, 0x70, 0x62, 0x2f,
0x77, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c,
0x6f, 0x77, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x22, 0x0a, 0x0c, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x44, 0x61, 0x74, 0x61, 0x12,
0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44,
0x61, 0x74, 0x61, 0x32, 0x47, 0x0a, 0x08, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12,
0x3b, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x16, 0x2e, 0x77, 0x6f, 0x72,
0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x44, 0x61,
0x74, 0x61, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06,
0x2e, 0x2f, 0x77, 0x66, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_workflow_wfpb_wf_proto_rawDescOnce sync.Once
file_workflow_wfpb_wf_proto_rawDescData = file_workflow_wfpb_wf_proto_rawDesc
)
func file_workflow_wfpb_wf_proto_rawDescGZIP() []byte {
file_workflow_wfpb_wf_proto_rawDescOnce.Do(func() {
file_workflow_wfpb_wf_proto_rawDescData = protoimpl.X.CompressGZIP(file_workflow_wfpb_wf_proto_rawDescData)
})
return file_workflow_wfpb_wf_proto_rawDescData
}
var file_workflow_wfpb_wf_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_workflow_wfpb_wf_proto_goTypes = []interface{}{
(*WorkflowData)(nil), // 0: workflow.WorkflowData
(*emptypb.Empty)(nil), // 1: google.protobuf.Empty
}
var file_workflow_wfpb_wf_proto_depIdxs = []int32{
0, // 0: workflow.Workflow.Execute:input_type -> workflow.WorkflowData
1, // 1: workflow.Workflow.Execute:output_type -> google.protobuf.Empty
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_workflow_wfpb_wf_proto_init() }
func file_workflow_wfpb_wf_proto_init() {
if File_workflow_wfpb_wf_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_workflow_wfpb_wf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*WorkflowData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_workflow_wfpb_wf_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_workflow_wfpb_wf_proto_goTypes,
DependencyIndexes: file_workflow_wfpb_wf_proto_depIdxs,
MessageInfos: file_workflow_wfpb_wf_proto_msgTypes,
}.Build()
File_workflow_wfpb_wf_proto = out.File
file_workflow_wfpb_wf_proto_rawDesc = nil
file_workflow_wfpb_wf_proto_goTypes = nil
file_workflow_wfpb_wf_proto_depIdxs = nil
}

0
dtmgrpc/workflow/wfpb/wf.proto → client/workflow/wfpb/wf.proto

4
dtmgrpc/workflow/wfpb/wf_grpc.pb.go → client/workflow/wfpb/wf_grpc.pb.go

@ -2,7 +2,7 @@
// versions: // versions:
// - protoc-gen-go-grpc v1.2.0 // - protoc-gen-go-grpc v1.2.0
// - protoc v3.17.3 // - protoc v3.17.3
// source: dtmgrpc/workflow/wfpb/wf.proto // source: workflow/wfpb/wf.proto
package wfpb package wfpb
@ -102,5 +102,5 @@ var Workflow_ServiceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "dtmgrpc/workflow/wfpb/wf.proto", Metadata: "workflow/wfpb/wf.proto",
} }

10
dtmgrpc/workflow/workflow.go → client/workflow/workflow.go

@ -7,11 +7,11 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/workflow/wfpb" "github.com/dtm-labs/dtm/client/workflow/wfpb"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

2
dtmgrpc/workflow/workflow_test.go → client/workflow/workflow_test.go

@ -4,7 +4,7 @@ import (
"context" "context"
"testing" "testing"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

1
conf.sample.yml

@ -68,3 +68,4 @@
### advanced options ### advanced options
# UpdateBranchAsyncGoroutineNum: 1 # num of async goroutine to update branch status # UpdateBranchAsyncGoroutineNum: 1 # num of async goroutine to update branch status
# TimeZoneOffset: '' #default '' using system default. '+8': Asia/Shanghai; '0': GMT

62
dtmcli/utils.go

@ -1,62 +0,0 @@
package dtmcli
import (
"errors"
"fmt"
"net/http"
"github.com/dtm-labs/dtm/dtmcli/dtmimp"
"github.com/go-resty/resty/v2"
)
// 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"]
}
// String2DtmError translate string to dtm error
func String2DtmError(str string) error {
return map[string]error{
ResultFailure: ErrFailure,
ResultOngoing: ErrOngoing,
ResultSuccess: nil,
"": nil,
}[str]
}
// Result2HttpJSON return the http code and json result
// if result is error, the return proper code, else return StatusOK
func Result2HttpJSON(result interface{}) (code int, res interface{}) {
err, _ := result.(error)
if err == nil {
code = http.StatusOK
res = result
} else {
res = map[string]string{
"error": err.Error(),
}
if errors.Is(err, ErrFailure) {
code = http.StatusConflict
} else if errors.Is(err, ErrOngoing) {
code = http.StatusTooEarly
} else if err != nil {
code = http.StatusInternalServerError
}
}
return
}
// IsRollback returns whether the result is indicating rollback
func IsRollback(resp *resty.Response, err error) bool {
return err == ErrFailure || dtmimp.RespAsErrorCompatible(resp) == ErrFailure
}
// IsOngoing returns whether the result is indicating ongoing
func IsOngoing(resp *resty.Response, err error) bool {
return err == ErrOngoing || dtmimp.RespAsErrorCompatible(resp) == ErrOngoing
}

736
dtmgrpc/dtmgpb/dtmgimp.pb.go

@ -1,736 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.17.3
// source: dtmgrpc/dtmgpb/dtmgimp.proto
package dtmgpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type DtmTransOptions struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
WaitResult bool `protobuf:"varint,1,opt,name=WaitResult,proto3" json:"WaitResult,omitempty"`
TimeoutToFail int64 `protobuf:"varint,2,opt,name=TimeoutToFail,proto3" json:"TimeoutToFail,omitempty"`
RetryInterval int64 `protobuf:"varint,3,opt,name=RetryInterval,proto3" json:"RetryInterval,omitempty"`
PassthroughHeaders []string `protobuf:"bytes,4,rep,name=PassthroughHeaders,proto3" json:"PassthroughHeaders,omitempty"`
BranchHeaders map[string]string `protobuf:"bytes,5,rep,name=BranchHeaders,proto3" json:"BranchHeaders,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
RequestTimeout int64 `protobuf:"varint,6,opt,name=RequestTimeout,proto3" json:"RequestTimeout,omitempty"`
}
func (x *DtmTransOptions) Reset() {
*x = DtmTransOptions{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmTransOptions) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmTransOptions) ProtoMessage() {}
func (x *DtmTransOptions) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmTransOptions.ProtoReflect.Descriptor instead.
func (*DtmTransOptions) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{0}
}
func (x *DtmTransOptions) GetWaitResult() bool {
if x != nil {
return x.WaitResult
}
return false
}
func (x *DtmTransOptions) GetTimeoutToFail() int64 {
if x != nil {
return x.TimeoutToFail
}
return 0
}
func (x *DtmTransOptions) GetRetryInterval() int64 {
if x != nil {
return x.RetryInterval
}
return 0
}
func (x *DtmTransOptions) GetPassthroughHeaders() []string {
if x != nil {
return x.PassthroughHeaders
}
return nil
}
func (x *DtmTransOptions) GetBranchHeaders() map[string]string {
if x != nil {
return x.BranchHeaders
}
return nil
}
func (x *DtmTransOptions) GetRequestTimeout() int64 {
if x != nil {
return x.RequestTimeout
}
return 0
}
// DtmRequest request sent to dtm server
type DtmRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
TransOptions *DtmTransOptions `protobuf:"bytes,3,opt,name=TransOptions,proto3" json:"TransOptions,omitempty"`
CustomedData string `protobuf:"bytes,4,opt,name=CustomedData,proto3" json:"CustomedData,omitempty"`
BinPayloads [][]byte `protobuf:"bytes,5,rep,name=BinPayloads,proto3" json:"BinPayloads,omitempty"` // for Msg/Saga/Workflow branch payloads
QueryPrepared string `protobuf:"bytes,6,opt,name=QueryPrepared,proto3" json:"QueryPrepared,omitempty"` // for Msg
Steps string `protobuf:"bytes,7,opt,name=Steps,proto3" json:"Steps,omitempty"`
ReqExtra map[string]string `protobuf:"bytes,8,rep,name=ReqExtra,proto3" json:"ReqExtra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
RollbackReason string `protobuf:"bytes,9,opt,name=RollbackReason,proto3" json:"RollbackReason,omitempty"`
}
func (x *DtmRequest) Reset() {
*x = DtmRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmRequest) ProtoMessage() {}
func (x *DtmRequest) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmRequest.ProtoReflect.Descriptor instead.
func (*DtmRequest) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{1}
}
func (x *DtmRequest) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmRequest) GetTransType() string {
if x != nil {
return x.TransType
}
return ""
}
func (x *DtmRequest) GetTransOptions() *DtmTransOptions {
if x != nil {
return x.TransOptions
}
return nil
}
func (x *DtmRequest) GetCustomedData() string {
if x != nil {
return x.CustomedData
}
return ""
}
func (x *DtmRequest) GetBinPayloads() [][]byte {
if x != nil {
return x.BinPayloads
}
return nil
}
func (x *DtmRequest) GetQueryPrepared() string {
if x != nil {
return x.QueryPrepared
}
return ""
}
func (x *DtmRequest) GetSteps() string {
if x != nil {
return x.Steps
}
return ""
}
func (x *DtmRequest) GetReqExtra() map[string]string {
if x != nil {
return x.ReqExtra
}
return nil
}
func (x *DtmRequest) GetRollbackReason() string {
if x != nil {
return x.RollbackReason
}
return ""
}
type DtmGidReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
}
func (x *DtmGidReply) Reset() {
*x = DtmGidReply{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmGidReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmGidReply) ProtoMessage() {}
func (x *DtmGidReply) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmGidReply.ProtoReflect.Descriptor instead.
func (*DtmGidReply) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{2}
}
func (x *DtmGidReply) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
type DtmBranchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
Op string `protobuf:"bytes,4,opt,name=Op,proto3" json:"Op,omitempty"`
Data map[string]string `protobuf:"bytes,5,rep,name=Data,proto3" json:"Data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
BusiPayload []byte `protobuf:"bytes,6,opt,name=BusiPayload,proto3" json:"BusiPayload,omitempty"`
}
func (x *DtmBranchRequest) Reset() {
*x = DtmBranchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmBranchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmBranchRequest) ProtoMessage() {}
func (x *DtmBranchRequest) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmBranchRequest.ProtoReflect.Descriptor instead.
func (*DtmBranchRequest) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{3}
}
func (x *DtmBranchRequest) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmBranchRequest) GetTransType() string {
if x != nil {
return x.TransType
}
return ""
}
func (x *DtmBranchRequest) GetBranchID() string {
if x != nil {
return x.BranchID
}
return ""
}
func (x *DtmBranchRequest) GetOp() string {
if x != nil {
return x.Op
}
return ""
}
func (x *DtmBranchRequest) GetData() map[string]string {
if x != nil {
return x.Data
}
return nil
}
func (x *DtmBranchRequest) GetBusiPayload() []byte {
if x != nil {
return x.BusiPayload
}
return nil
}
type DtmProgressesReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Progresses []*DtmProgress `protobuf:"bytes,1,rep,name=Progresses,proto3" json:"Progresses,omitempty"`
}
func (x *DtmProgressesReply) Reset() {
*x = DtmProgressesReply{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmProgressesReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmProgressesReply) ProtoMessage() {}
func (x *DtmProgressesReply) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmProgressesReply.ProtoReflect.Descriptor instead.
func (*DtmProgressesReply) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{4}
}
func (x *DtmProgressesReply) GetProgresses() []*DtmProgress {
if x != nil {
return x.Progresses
}
return nil
}
type DtmProgress struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Status string `protobuf:"bytes,1,opt,name=Status,proto3" json:"Status,omitempty"`
BinData []byte `protobuf:"bytes,2,opt,name=BinData,proto3" json:"BinData,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
Op string `protobuf:"bytes,4,opt,name=Op,proto3" json:"Op,omitempty"`
}
func (x *DtmProgress) Reset() {
*x = DtmProgress{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmProgress) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmProgress) ProtoMessage() {}
func (x *DtmProgress) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DtmProgress.ProtoReflect.Descriptor instead.
func (*DtmProgress) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{5}
}
func (x *DtmProgress) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *DtmProgress) GetBinData() []byte {
if x != nil {
return x.BinData
}
return nil
}
func (x *DtmProgress) GetBranchID() string {
if x != nil {
return x.BranchID
}
return ""
}
func (x *DtmProgress) GetOp() string {
if x != nil {
return x.Op
}
return ""
}
var File_dtmgrpc_dtmgpb_dtmgimp_proto protoreflect.FileDescriptor
var file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = []byte{
0x0a, 0x1c, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70, 0x62,
0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07,
0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xea, 0x02, 0x0a, 0x0f, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74,
0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x57, 0x61,
0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x54, 0x69, 0x6d, 0x65,
0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x0d, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x12, 0x24,
0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18,
0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65,
0x72, 0x76, 0x61, 0x6c, 0x12, 0x2e, 0x0a, 0x12, 0x50, 0x61, 0x73, 0x73, 0x74, 0x68, 0x72, 0x6f,
0x75, 0x67, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09,
0x52, 0x12, 0x50, 0x61, 0x73, 0x73, 0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x48, 0x65, 0x61,
0x64, 0x65, 0x72, 0x73, 0x12, 0x51, 0x0a, 0x0d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x64, 0x74,
0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64,
0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52,
0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a,
0x40, 0x0a, 0x12, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
0x01, 0x22, 0xa0, 0x03, 0x0a, 0x0a, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47,
0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65,
0x12, 0x3c, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70,
0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x52, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22,
0x0a, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x64, 0x44, 0x61,
0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6c,
0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65,
0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x51, 0x75, 0x65,
0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x74,
0x65, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x53, 0x74, 0x65, 0x70, 0x73,
0x12, 0x3d, 0x0a, 0x08, 0x52, 0x65, 0x71, 0x45, 0x78, 0x74, 0x72, 0x61, 0x18, 0x08, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x45, 0x78, 0x74, 0x72, 0x61,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x52, 0x65, 0x71, 0x45, 0x78, 0x74, 0x72, 0x61, 0x12,
0x26, 0x0a, 0x0e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f,
0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63,
0x6b, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x1a, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x45, 0x78,
0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x3a, 0x02, 0x38, 0x01, 0x22, 0x1f, 0x0a, 0x0b, 0x44, 0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x47, 0x69, 0x64, 0x22, 0x82, 0x02, 0x0a, 0x10, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61,
0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x42, 0x72,
0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x42, 0x72,
0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x4f, 0x70, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x4f, 0x70, 0x12, 0x37, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44,
0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e,
0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12,
0x20, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4a, 0x0a, 0x12, 0x44, 0x74,
0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79,
0x12, 0x34, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44,
0x74, 0x6d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0a, 0x50, 0x72, 0x6f, 0x67,
0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x6b, 0x0a, 0x0b, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f,
0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a,
0x07, 0x42, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07,
0x42, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63,
0x68, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x42, 0x72, 0x61, 0x6e, 0x63,
0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x4f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x4f, 0x70, 0x32, 0xf8, 0x02, 0x0a, 0x03, 0x44, 0x74, 0x6d, 0x12, 0x38, 0x0a, 0x06, 0x4e,
0x65, 0x77, 0x47, 0x69, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e,
0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12,
0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x38,
0x0a, 0x07, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67,
0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x05, 0x41, 0x62, 0x6f, 0x72,
0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00,
0x12, 0x45, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x12, 0x19, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d,
0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0f, 0x50, 0x72, 0x65, 0x70, 0x61,
0x72, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d,
0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x50, 0x72, 0x6f,
0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0a,
0x5a, 0x08, 0x2e, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce sync.Once
file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc
)
func file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP() []byte {
file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce.Do(func() {
file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = protoimpl.X.CompressGZIP(file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData)
})
return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData
}
var file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = []interface{}{
(*DtmTransOptions)(nil), // 0: dtmgimp.DtmTransOptions
(*DtmRequest)(nil), // 1: dtmgimp.DtmRequest
(*DtmGidReply)(nil), // 2: dtmgimp.DtmGidReply
(*DtmBranchRequest)(nil), // 3: dtmgimp.DtmBranchRequest
(*DtmProgressesReply)(nil), // 4: dtmgimp.DtmProgressesReply
(*DtmProgress)(nil), // 5: dtmgimp.DtmProgress
nil, // 6: dtmgimp.DtmTransOptions.BranchHeadersEntry
nil, // 7: dtmgimp.DtmRequest.ReqExtraEntry
nil, // 8: dtmgimp.DtmBranchRequest.DataEntry
(*emptypb.Empty)(nil), // 9: google.protobuf.Empty
}
var file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = []int32{
6, // 0: dtmgimp.DtmTransOptions.BranchHeaders:type_name -> dtmgimp.DtmTransOptions.BranchHeadersEntry
0, // 1: dtmgimp.DtmRequest.TransOptions:type_name -> dtmgimp.DtmTransOptions
7, // 2: dtmgimp.DtmRequest.ReqExtra:type_name -> dtmgimp.DtmRequest.ReqExtraEntry
8, // 3: dtmgimp.DtmBranchRequest.Data:type_name -> dtmgimp.DtmBranchRequest.DataEntry
5, // 4: dtmgimp.DtmProgressesReply.Progresses:type_name -> dtmgimp.DtmProgress
9, // 5: dtmgimp.Dtm.NewGid:input_type -> google.protobuf.Empty
1, // 6: dtmgimp.Dtm.Submit:input_type -> dtmgimp.DtmRequest
1, // 7: dtmgimp.Dtm.Prepare:input_type -> dtmgimp.DtmRequest
1, // 8: dtmgimp.Dtm.Abort:input_type -> dtmgimp.DtmRequest
3, // 9: dtmgimp.Dtm.RegisterBranch:input_type -> dtmgimp.DtmBranchRequest
1, // 10: dtmgimp.Dtm.PrepareWorkflow:input_type -> dtmgimp.DtmRequest
2, // 11: dtmgimp.Dtm.NewGid:output_type -> dtmgimp.DtmGidReply
9, // 12: dtmgimp.Dtm.Submit:output_type -> google.protobuf.Empty
9, // 13: dtmgimp.Dtm.Prepare:output_type -> google.protobuf.Empty
9, // 14: dtmgimp.Dtm.Abort:output_type -> google.protobuf.Empty
9, // 15: dtmgimp.Dtm.RegisterBranch:output_type -> google.protobuf.Empty
4, // 16: dtmgimp.Dtm.PrepareWorkflow:output_type -> dtmgimp.DtmProgressesReply
11, // [11:17] is the sub-list for method output_type
5, // [5:11] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_dtmgrpc_dtmgpb_dtmgimp_proto_init() }
func file_dtmgrpc_dtmgpb_dtmgimp_proto_init() {
if File_dtmgrpc_dtmgpb_dtmgimp_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmTransOptions); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmGidReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmBranchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmProgressesReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmProgress); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes,
DependencyIndexes: file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs,
MessageInfos: file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes,
}.Build()
File_dtmgrpc_dtmgpb_dtmgimp_proto = out.File
file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = nil
file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = nil
file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = nil
}

153
dtmgrpc/workflow/wfpb/wf.pb.go

@ -1,153 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.17.3
// source: dtmgrpc/workflow/wfpb/wf.proto
package wfpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type WorkflowData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *WorkflowData) Reset() {
*x = WorkflowData{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_workflow_wfpb_wf_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WorkflowData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WorkflowData) ProtoMessage() {}
func (x *WorkflowData) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_workflow_wfpb_wf_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use WorkflowData.ProtoReflect.Descriptor instead.
func (*WorkflowData) Descriptor() ([]byte, []int) {
return file_dtmgrpc_workflow_wfpb_wf_proto_rawDescGZIP(), []int{0}
}
func (x *WorkflowData) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
var File_dtmgrpc_workflow_wfpb_wf_proto protoreflect.FileDescriptor
var file_dtmgrpc_workflow_wfpb_wf_proto_rawDesc = []byte{
0x0a, 0x1e, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c,
0x6f, 0x77, 0x2f, 0x77, 0x66, 0x70, 0x62, 0x2f, 0x77, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74,
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0c, 0x57, 0x6f, 0x72, 0x6b, 0x66,
0x6c, 0x6f, 0x77, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x32, 0x47, 0x0a, 0x08, 0x57,
0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x3b, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75,
0x74, 0x65, 0x12, 0x16, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x57, 0x6f,
0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x44, 0x61, 0x74, 0x61, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x77, 0x66, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_dtmgrpc_workflow_wfpb_wf_proto_rawDescOnce sync.Once
file_dtmgrpc_workflow_wfpb_wf_proto_rawDescData = file_dtmgrpc_workflow_wfpb_wf_proto_rawDesc
)
func file_dtmgrpc_workflow_wfpb_wf_proto_rawDescGZIP() []byte {
file_dtmgrpc_workflow_wfpb_wf_proto_rawDescOnce.Do(func() {
file_dtmgrpc_workflow_wfpb_wf_proto_rawDescData = protoimpl.X.CompressGZIP(file_dtmgrpc_workflow_wfpb_wf_proto_rawDescData)
})
return file_dtmgrpc_workflow_wfpb_wf_proto_rawDescData
}
var file_dtmgrpc_workflow_wfpb_wf_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_dtmgrpc_workflow_wfpb_wf_proto_goTypes = []interface{}{
(*WorkflowData)(nil), // 0: workflow.WorkflowData
(*emptypb.Empty)(nil), // 1: google.protobuf.Empty
}
var file_dtmgrpc_workflow_wfpb_wf_proto_depIdxs = []int32{
0, // 0: workflow.Workflow.Execute:input_type -> workflow.WorkflowData
1, // 1: workflow.Workflow.Execute:output_type -> google.protobuf.Empty
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_dtmgrpc_workflow_wfpb_wf_proto_init() }
func file_dtmgrpc_workflow_wfpb_wf_proto_init() {
if File_dtmgrpc_workflow_wfpb_wf_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_dtmgrpc_workflow_wfpb_wf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*WorkflowData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_dtmgrpc_workflow_wfpb_wf_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_dtmgrpc_workflow_wfpb_wf_proto_goTypes,
DependencyIndexes: file_dtmgrpc_workflow_wfpb_wf_proto_depIdxs,
MessageInfos: file_dtmgrpc_workflow_wfpb_wf_proto_msgTypes,
}.Build()
File_dtmgrpc_workflow_wfpb_wf_proto = out.File
file_dtmgrpc_workflow_wfpb_wf_proto_rawDesc = nil
file_dtmgrpc_workflow_wfpb_wf_proto_goTypes = nil
file_dtmgrpc_workflow_wfpb_wf_proto_depIdxs = nil
}

35
dtmsvr/api.go

@ -8,10 +8,11 @@ package dtmsvr
import ( import (
"fmt" "fmt"
"time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
) )
@ -19,10 +20,12 @@ import (
var Version = "" var Version = ""
func svcSubmit(t *TransGlobal) interface{} { func svcSubmit(t *TransGlobal) interface{} {
t.Status = dtmcli.StatusSubmitted if t.TransType == "workflow" {
if t.ReqExtra != nil && t.ReqExtra["status"] != "" { t.Status = dtmcli.StatusPrepared
t.Status = t.ReqExtra["status"] t.changeStatus(t.ReqExtra["status"], withRollbackReason(t.ReqExtra["rollback_reason"]))
return nil
} }
t.Status = dtmcli.StatusSubmitted
branches, err := t.saveNew() branches, err := t.saveNew()
if err == storage.ErrUniqueConflict { if err == storage.ErrUniqueConflict {
@ -50,13 +53,14 @@ func svcPrepare(t *TransGlobal) interface{} {
return err return err
} }
func svcPrepareWorkflow(t *TransGlobal) ([]TransBranch, error) { func svcPrepareWorkflow(t *TransGlobal) (*storage.TransGlobalStore, []TransBranch, error) {
t.Status = dtmcli.StatusPrepared t.Status = dtmcli.StatusPrepared
_, err := t.saveNew() _, err := t.saveNew()
if err == storage.ErrUniqueConflict { // transaction exists, query the branches if err == storage.ErrUniqueConflict { // transaction exists, query the branches
return GetStore().FindBranches(t.Gid), nil st := GetStore()
return st.FindTransGlobalStore(t.Gid), st.FindBranches(t.Gid), nil
} }
return []TransBranch{}, err return &t.TransGlobalStore, []TransBranch{}, err
} }
func svcAbort(t *TransGlobal) interface{} { func svcAbort(t *TransGlobal) interface{} {
@ -95,6 +99,17 @@ func svcRegisterBranch(transType string, branch *TransBranch, data map[string]st
branches[1].Op = dtmimp.OpCommit branches[1].Op = dtmimp.OpCommit
branches[1].URL = data["url"] branches[1].URL = data["url"]
} else if transType == "workflow" { } else if transType == "workflow" {
if data["sync"] == "" && conf.UpdateBranchSync == 0 {
now := time.Now()
updateBranchAsyncChan <- branchStatus{
gid: branch.Gid,
branchID: branch.BranchID,
op: data["op"],
status: data["status"],
finishTime: &now,
}
return nil
}
branches = []TransBranch{*branch} branches = []TransBranch{*branch}
branches[0].Status = data["status"] branches[0].Status = data["status"]
branches[0].Op = data["op"] branches[0].Op = data["op"]
@ -108,7 +123,7 @@ func svcRegisterBranch(transType string, branch *TransBranch, data map[string]st
if err == storage.ErrNotFound { if err == storage.ErrNotFound {
msg := fmt.Sprintf("no trans with gid: %s status: %s found", branch.Gid, dtmcli.StatusPrepared) msg := fmt.Sprintf("no trans with gid: %s status: %s found", branch.Gid, dtmcli.StatusPrepared)
logger.Errorf(msg) logger.Errorf(msg)
return fmt.Errorf("message: %s %w", msg, dtmcli.ErrFailure) return dtmcli.ErrorMessage2Error(msg, dtmcli.ErrFailure)
} }
logger.Infof("LockGlobalSaveBranches result: %v: gid: %s old status: %s branches: %s", logger.Infof("LockGlobalSaveBranches result: %v: gid: %s old status: %s branches: %s",
err, branch.Gid, dtmcli.StatusPrepared, dtmimp.MustMarshalString(branches)) err, branch.Gid, dtmcli.StatusPrepared, dtmimp.MustMarshalString(branches))

13
dtmsvr/api_grpc.go

@ -9,9 +9,9 @@ package dtmsvr
import ( import (
"context" "context"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmgrpc" "github.com/dtm-labs/dtm/client/dtmgrpc"
pb "github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" pb "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/emptypb"
) )
@ -50,8 +50,13 @@ func (s *dtmServer) RegisterBranch(ctx context.Context, in *pb.DtmBranchRequest)
} }
func (s *dtmServer) PrepareWorkflow(ctx context.Context, in *pb.DtmRequest) (*pb.DtmProgressesReply, error) { func (s *dtmServer) PrepareWorkflow(ctx context.Context, in *pb.DtmRequest) (*pb.DtmProgressesReply, error) {
branches, err := svcPrepareWorkflow(TransFromDtmRequest(ctx, in)) trans, branches, err := svcPrepareWorkflow(TransFromDtmRequest(ctx, in))
reply := &pb.DtmProgressesReply{ reply := &pb.DtmProgressesReply{
Transaction: &pb.DtmTransaction{
Gid: trans.Gid,
Status: trans.Status,
RollbackReason: trans.RollbackReason,
},
Progresses: []*pb.DtmProgress{}, Progresses: []*pb.DtmProgress{},
} }
for _, b := range branches { for _, b := range branches {

8
dtmsvr/api_http.go

@ -11,8 +11,8 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
@ -87,11 +87,11 @@ func query(c *gin.Context) interface{} {
} }
func prepareWorkflow(c *gin.Context) interface{} { func prepareWorkflow(c *gin.Context) interface{} {
branches, err := svcPrepareWorkflow(TransFromContext(c)) trans, branches, err := svcPrepareWorkflow(TransFromContext(c))
if err != nil { if err != nil {
return err return err
} }
return branches return map[string]interface{}{"Transaction": trans, "Progresses": branches}
} }
func all(c *gin.Context) interface{} { func all(c *gin.Context) interface{} {

6
dtmsvr/api_json_rpc.go

@ -6,9 +6,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

5
dtmsvr/config/config.go

@ -4,8 +4,8 @@ import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
@ -95,6 +95,7 @@ type Type struct {
UpdateBranchAsyncGoroutineNum int64 `yaml:"UpdateBranchAsyncGoroutineNum" default:"1"` UpdateBranchAsyncGoroutineNum int64 `yaml:"UpdateBranchAsyncGoroutineNum" default:"1"`
LogLevel string `yaml:"LogLevel" default:"info"` LogLevel string `yaml:"LogLevel" default:"info"`
Log Log `yaml:"Log"` Log Log `yaml:"Log"`
TimeZoneOffset string `yaml:"TimeZoneOffset"`
} }
// Config config // Config config

2
dtmsvr/config/config_utils.go

@ -8,7 +8,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
) )
func loadFromEnv(prefix string, conf interface{}) { func loadFromEnv(prefix string, conf interface{}) {

6
dtmsvr/cron.go

@ -13,9 +13,9 @@ import (
"runtime/debug" "runtime/debug"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
// NowForwardDuration will be set in test, trans may be timeout // NowForwardDuration will be set in test, trans may be timeout

7
dtmsvr/entry/main.go

@ -5,8 +5,10 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"time"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr" "github.com/dtm-labs/dtm/dtmsvr"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage/registry" "github.com/dtm-labs/dtm/dtmsvr/storage/registry"
@ -43,6 +45,9 @@ func Main(version *string) (*gin.Engine, *config.Type) {
} }
logger.Infof("dtm version is: %s", *version) logger.Infof("dtm version is: %s", *version)
config.MustLoadConfig(*confFile) config.MustLoadConfig(*confFile)
if config.Config.TimeZoneOffset != "" {
time.Local = time.FixedZone("UTC", dtmimp.MustAtoi(config.Config.TimeZoneOffset)*3600)
}
conf := &config.Config conf := &config.Config
if *isDebug { if *isDebug {
conf.LogLevel = "debug" conf.LogLevel = "debug"

4
dtmsvr/storage/boltdb/boltdb.go

@ -11,8 +11,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"

2
dtmsvr/storage/boltdb/boltdb_test.go

@ -14,7 +14,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
) )

4
dtmsvr/storage/redis/redis.go

@ -15,8 +15,8 @@ import (
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"

2
dtmsvr/storage/registry/registry.go

@ -3,7 +3,7 @@ package registry
import ( import (
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"

4
dtmsvr/storage/sql/sql.go

@ -11,7 +11,7 @@ import (
"math" "math"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
@ -77,7 +77,7 @@ func (s *Store) FindBranches(gid string) []storage.TransBranchStore {
// UpdateBranches update branches info // UpdateBranches update branches info
func (s *Store) UpdateBranches(branches []storage.TransBranchStore, updates []string) (int, error) { func (s *Store) UpdateBranches(branches []storage.TransBranchStore, updates []string) (int, error) {
db := dbGet().Clauses(clause.OnConflict{ db := dbGet().Clauses(clause.OnConflict{
OnConstraint: "trans_branch_op_pkey", OnConstraint: "gid_branch_uniq",
DoUpdates: clause.AssignmentColumns(updates), DoUpdates: clause.AssignmentColumns(updates),
}).Create(branches) }).Create(branches)
return int(db.RowsAffected), db.Error return int(db.RowsAffected), db.Error

4
dtmsvr/storage/trans.go

@ -9,8 +9,8 @@ package storage
import ( import (
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
) )

47
dtmsvr/svr.go

@ -12,16 +12,18 @@ import (
"net" "net"
"time" "time"
"github.com/dtm-labs/dtm/dtmgrpc" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtmdriver" "github.com/dtm-labs/dtmdriver"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
// StartSvr StartSvr // StartSvr StartSvr
@ -56,7 +58,7 @@ func StartSvr() *gin.Engine {
// start grpc server // start grpc server
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", conf.GrpcPort)) lis, err := net.Listen("tcp", fmt.Sprintf(":%d", conf.GrpcPort))
logger.FatalIfError(err) logger.FatalIfError(err)
s := grpc.NewServer(grpc.ChainUnaryInterceptor(grpcMetrics, dtmgimp.GrpcServerLog)) s := grpc.NewServer(grpc.ChainUnaryInterceptor(grpcRecover, grpcMetrics, dtmgimp.GrpcServerLog))
dtmgpb.RegisterDtmServer(s, &dtmServer{}) dtmgpb.RegisterDtmServer(s, &dtmServer{})
logger.Infof("grpc listening at %v", lis.Addr()) logger.Infof("grpc listening at %v", lis.Addr())
go func() { go func() {
@ -99,23 +101,27 @@ func updateBranchAsync() {
flushBranchs := func() { flushBranchs := func() {
defer dtmutil.RecoverPanic(nil) defer dtmutil.RecoverPanic(nil)
updates := []TransBranch{} updates := []TransBranch{}
exists := map[string]bool{}
started := time.Now() started := time.Now()
checkInterval := 20 * time.Millisecond checkInterval := 20 * time.Millisecond
for time.Since(started) < UpdateBranchAsyncInterval-checkInterval && len(updates) < 20 { for time.Since(started) < UpdateBranchAsyncInterval-checkInterval && len(updates) < 20 {
select { select {
case updateBranch := <-updateBranchAsyncChan: case updateBranch := <-updateBranchAsyncChan:
updates = append(updates, TransBranch{ k := updateBranch.gid + updateBranch.branchID + "-" + updateBranch.op
ModelBase: dtmutil.ModelBase{ID: updateBranch.id}, if !exists[k] { // postgres does not allow
Gid: updateBranch.gid, exists[k] = true
BranchID: updateBranch.branchID, updates = append(updates, TransBranch{
Op: updateBranch.op, Gid: updateBranch.gid,
Status: updateBranch.status, BranchID: updateBranch.branchID,
FinishTime: updateBranch.finishTime, Op: updateBranch.op,
}) Status: updateBranch.status,
FinishTime: updateBranch.finishTime,
})
}
case <-time.After(checkInterval): case <-time.After(checkInterval):
} }
} }
for len(updates) > 0 { for i := 0; i < 3 && len(updates) > 0; i++ {
rowAffected, err := GetStore().UpdateBranches(updates, []string{"status", "finish_time", "update_time"}) rowAffected, err := GetStore().UpdateBranches(updates, []string{"status", "finish_time", "update_time"})
if err != nil { if err != nil {
@ -132,3 +138,14 @@ func updateBranchAsync() {
flushBranchs() flushBranchs()
} }
} }
func grpcRecover(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (res interface{}, rerr error) {
defer func() {
if x := recover(); x != nil {
rerr = status.Errorf(codes.Internal, "%v", x)
logger.Errorf("dtm server panic: %v", x)
}
}()
res, rerr = handler(ctx, req)
return
}

10
dtmsvr/trans_class.go

@ -4,11 +4,11 @@ import (
"context" "context"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

8
dtmsvr/trans_process.go

@ -11,9 +11,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
) )
@ -49,7 +49,7 @@ func (t *TransGlobal) process(branches []TransBranch) error {
if submitting && t.Status != dtmcli.StatusSucceed { if submitting && t.Status != dtmcli.StatusSucceed {
if t.RollbackReason != "" { if t.RollbackReason != "" {
return fmt.Errorf("%s. %w", t.RollbackReason, dtmcli.ErrFailure) return dtmcli.ErrorMessage2Error(t.RollbackReason, dtmcli.ErrFailure)
} }
return fmt.Errorf("wait result not return success: %w", dtmcli.ErrFailure) return fmt.Errorf("wait result not return success: %w", dtmcli.ErrFailure)
} }

16
dtmsvr/trans_status.go

@ -7,11 +7,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtmdriver" "github.com/dtm-labs/dtmdriver"
"github.com/lithammer/shortuuid/v3" "github.com/lithammer/shortuuid/v3"
@ -81,7 +81,7 @@ func (t *TransGlobal) changeBranchStatus(b *TransBranch, status string, branchPo
logger.Infof("LockGlobalSaveBranches ok: gid: %s old status: %s branches: %s", logger.Infof("LockGlobalSaveBranches ok: gid: %s old status: %s branches: %s",
b.Gid, dtmcli.StatusPrepared, b.String()) b.Gid, dtmcli.StatusPrepared, b.String())
} else { // for better performance, batch the updates of branch status } else { // for better performance, batch the updates of branch status
updateBranchAsyncChan <- branchStatus{id: b.ID, gid: t.Gid, branchID: b.BranchID, op: b.Op, status: status, finishTime: &now} updateBranchAsyncChan <- branchStatus{gid: t.Gid, branchID: b.BranchID, op: b.Op, status: status, finishTime: &now}
} }
} }
@ -135,7 +135,7 @@ func (t *TransGlobal) getHTTPResult(uri string, branchID, op string, branchPaylo
if err != nil { if err != nil {
return err return err
} }
return dtmimp.RespAsErrorCompatible(resp) return dtmcli.HTTPResp2DtmError(resp)
} }
func (t *TransGlobal) getJSONRPCResult(uri string, branchID, op string, branchPayload []byte) error { func (t *TransGlobal) getJSONRPCResult(uri string, branchID, op string, branchPayload []byte) error {
@ -158,7 +158,7 @@ func (t *TransGlobal) getJSONRPCResult(uri string, branchID, op string, branchPa
SetHeaders(t.TransOptions.BranchHeaders). SetHeaders(t.TransOptions.BranchHeaders).
Post(uri) Post(uri)
if err == nil { if err == nil {
err = dtmimp.RespAsErrorCompatible(resp) err = dtmcli.HTTPResp2DtmError(resp)
} }
if err == nil { if err == nil {
err = dtmimp.RespAsErrorByJSONRPC(resp) err = dtmimp.RespAsErrorByJSONRPC(resp)

6
dtmsvr/trans_type_msg.go

@ -4,9 +4,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
type transMsgProcessor struct { type transMsgProcessor struct {

6
dtmsvr/trans_type_saga.go

@ -5,9 +5,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
type transSagaProcessor struct { type transSagaProcessor struct {

6
dtmsvr/trans_type_tcc.go

@ -3,9 +3,9 @@ package dtmsvr
import ( import (
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
type transTccProcessor struct { type transTccProcessor struct {

13
dtmsvr/trans_type_workflow.go

@ -1,10 +1,10 @@
package dtmsvr package dtmsvr
import ( import (
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/workflow/wfpb" "github.com/dtm-labs/dtm/client/workflow/wfpb"
) )
type transWorkflowProcessor struct { type transWorkflowProcessor struct {
@ -25,10 +25,7 @@ type cWorkflowCustom struct {
} }
func (t *transWorkflowProcessor) ProcessOnce(branches []TransBranch) error { func (t *transWorkflowProcessor) ProcessOnce(branches []TransBranch) error {
if t.Status == dtmcli.StatusSubmitted { // client workflow finished if t.Status == dtmcli.StatusFailed || t.Status == dtmcli.StatusSucceed {
t.changeStatus(dtmcli.StatusSucceed)
return nil
} else if t.Status == dtmcli.StatusFailed || t.Status == dtmcli.StatusSucceed {
return nil return nil
} }

4
dtmsvr/trans_type_xa.go

@ -3,8 +3,8 @@ package dtmsvr
import ( import (
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
) )
type transXaProcessor struct { type transXaProcessor struct {

3
dtmsvr/utils.go

@ -10,7 +10,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage" "github.com/dtm-labs/dtm/dtmsvr/storage"
"github.com/dtm-labs/dtm/dtmsvr/storage/registry" "github.com/dtm-labs/dtm/dtmsvr/storage/registry"
@ -18,7 +18,6 @@ import (
) )
type branchStatus struct { type branchStatus struct {
id uint64
gid string gid string
branchID string branchID string
op string op string

6
dtmutil/db.go

@ -6,9 +6,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
_ "github.com/go-sql-driver/mysql" // register mysql driver _ "github.com/go-sql-driver/mysql" // register mysql driver
_ "github.com/lib/pq" // register postgres driver _ "github.com/lib/pq" // register postgres driver
"gorm.io/driver/mysql" "gorm.io/driver/mysql"

6
dtmutil/utils.go

@ -20,9 +20,9 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
) )
// GetGinApp init and return gin // GetGinApp init and return gin

1
go.sum

@ -1251,3 +1251,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZa
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=

4
helper/bench/main.go

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr" "github.com/dtm-labs/dtm/dtmsvr"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/storage/registry" "github.com/dtm-labs/dtm/dtmsvr/storage/registry"

6
helper/bench/svr/http.go

@ -15,9 +15,9 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr" "github.com/dtm-labs/dtm/dtmsvr"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtm/test/busi" "github.com/dtm-labs/dtm/test/busi"

36
helper/sync-client.sh

@ -0,0 +1,36 @@
#! /bin/bash
set -x
ver=$1
if [ x$ver == x ]; then
echo please specify you version like vx.x.x;
exit 1;
fi
if [ ${ver:0:1} != v ]; then
echo please specify you version like vx.x.x;
exit 1;
fi
cd ../client
cp -rf ../dtm/client/* ./
sed -i '' -e 's/dtm-labs\/dtm\//dtm-labs\//g' */*.go */*/*.go
rm -rf */*_test.go */*/*_test.go */*log */*/*log
go mod tidy
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push
git tag $ver
git push --tags
cd ../quick-start-sample
go get -u github.com/dtm-labs/client@$ver
go mod tidy
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push

57
helper/sync-dtmcli.sh

@ -1,57 +0,0 @@
#! /bin/bash
set -x
ver=$1
if [ x$ver == x ]; then
echo please specify you version like vx.x.x;
exit 1;
fi
if [ ${ver:0:1} != v ]; then
echo please specify you version like vx.x.x;
exit 1;
fi
cd ../dtmcli
cp -rf ../dtm/dtmcli/* ./
rm -f *_test.go logger/*.log
sed -i '' -e 's/dtm-labs\/dtm\//dtm-labs\//g' *.go */**.go
go mod tidy
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push
git tag $ver
git push --tags
cd ../dtmcli-go-sample
go get -u github.com/dtm-labs/dtmcli@$ver
go mod tidy
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push
cd ../dtmgrpc
rm -rf *.go dtmgimp
cp -r ../dtm/dtmgrpc/* ./
go get github.com/dtm-labs/dtmcli@$ver
sed -i '' -e 's/dtm-labs\/dtm\//dtm-labs\//g' *.go */**.go
rm -rf *_test.go
rm -rf workflow/*_test.go
go mod tidy
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push
git tag $ver
git push --tags
cd ../dtmgrpc-go-sample
go get github.com/dtm-labs/dtmcli@$ver
go get github.com/dtm-labs/dtmgrpc@$ver
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative busi/*.proto || exit 1
go build || exit 1
git add .
git commit -m"update from dtm to version $ver"
git push

12
helper/test-cover.sh

@ -1,13 +1,11 @@
set -x set -x
echo "mode: count" > coverage.txt echo "mode: count" > coverage.txt
for store in redis boltdb mysql postgres; do for store in redis boltdb mysql postgres; do
for d in $(go list ./... | grep -v vendor); do TEST_STORE=$store go test -failfast -covermode count -coverprofile=profile.out -coverpkg=github.com/dtm-labs/dtm/client/dtmcli,github.com/dtm-labs/dtm/client/dtmcli/dtmimp,github.com/dtm-labs/dtm/client/dtmcli/logger,github.com/dtm-labs/dtm/client/dtmgrpc,github.com/dtm-labs/dtm/client/workflow,github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp,github.com/dtm-labs/dtm/dtmsvr,dtmsvr/config,github.com/dtm-labs/dtm/dtmsvr/storage,github.com/dtm-labs/dtm/dtmsvr/storage/boltdb,github.com/dtm-labs/dtm/dtmsvr/storage/redis,github.com/dtm-labs/dtm/dtmsvr/storage/registry,github.com/dtm-labs/dtm/dtmsvr/storage/sql,github.com/dtm-labs/dtm/dtmutil -gcflags=-l ./... || exit 1
TEST_STORE=$store go test -failfast -covermode count -coverprofile=profile.out -coverpkg=github.com/dtm-labs/dtm/dtmcli,github.com/dtm-labs/dtm/dtmcli/dtmimp,github.com/dtm-labs/dtm/dtmcli/logger,github.com/dtm-labs/dtm/dtmgrpc,github.com/dtm-labs/dtm/dtmgrpc/workflow,github.com/dtm-labs/dtm/dtmgrpc/dtmgimp,github.com/dtm-labs/dtm/dtmsvr,github.com/dtm-labs/dtm/dtmsvr/config,github.com/dtm-labs/dtm/dtmsvr/storage,github.com/dtm-labs/dtm/dtmsvr/storage/boltdb,github.com/dtm-labs/dtm/dtmsvr/storage/redis,github.com/dtm-labs/dtm/dtmsvr/storage/registry,github.com/dtm-labs/dtm/dtmsvr/storage/sql,github.com/dtm-labs/dtm/dtmutil -gcflags=-l $d || exit 1 if [ -f profile.out ]; then
if [ -f profile.out ]; then cat profile.out | grep -v 'mode:' >> coverage.txt
cat profile.out | grep -v 'mode:' >> coverage.txt echo > profile.out
echo > profile.out fi
fi
done
done done
# go tool cover -html=coverage.txt # go tool cover -html=coverage.txt

2
main.go

@ -19,7 +19,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/config"
"github.com/dtm-labs/dtm/dtmsvr/entry" "github.com/dtm-labs/dtm/dtmsvr/entry"
_ "github.com/dtm-labs/dtm/dtmsvr/microservices" _ "github.com/dtm-labs/dtm/dtmsvr/microservices"

2
test/api_test.go

@ -12,7 +12,7 @@ import (
"strconv" "strconv"
"testing" "testing"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtm/test/busi" "github.com/dtm-labs/dtm/test/busi"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

6
test/base_test.go

@ -11,9 +11,9 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtm/test/busi" "github.com/dtm-labs/dtm/test/busi"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

7
test/busi/barrier.go

@ -10,8 +10,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/dtm-labs/dtm/dtmgrpc"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -80,7 +79,7 @@ func init() {
app.POST(BusiAPI+"/TccBTransInTry", dtmutil.WrapHandler(func(c *gin.Context) interface{} { app.POST(BusiAPI+"/TccBTransInTry", dtmutil.WrapHandler(func(c *gin.Context) interface{} {
req := reqFrom(c) req := reqFrom(c)
if req.TransInResult != "" { if req.TransInResult != "" {
return dtmcli.String2DtmError(req.TransInResult) return string2DtmError(req.TransInResult)
} }
return MustBarrierFromGin(c).CallWithDB(pdbGet(), func(tx *sql.Tx) error { return MustBarrierFromGin(c).CallWithDB(pdbGet(), func(tx *sql.Tx) error {
return tccAdjustTrading(tx, TransInUID, req.Amount) return tccAdjustTrading(tx, TransInUID, req.Amount)
@ -159,7 +158,7 @@ func init() {
app.POST(BusiAPI+"/TccBTransOutTry", dtmutil.WrapHandler(func(c *gin.Context) interface{} { app.POST(BusiAPI+"/TccBTransOutTry", dtmutil.WrapHandler(func(c *gin.Context) interface{} {
req := reqFrom(c) req := reqFrom(c)
if req.TransOutResult != "" { if req.TransOutResult != "" {
return dtmcli.String2DtmError(req.TransOutResult) return string2DtmError(req.TransOutResult)
} }
bb := MustBarrierFromGin(c) bb := MustBarrierFromGin(c)
if req.Store == Redis { if req.Store == Redis {

34
test/busi/base_grpc.go

@ -12,18 +12,20 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/dtm-labs/dtm/dtmgrpc"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"github.com/dtm-labs/dtm/dtmgrpc/workflow" "github.com/dtm-labs/dtm/client/workflow"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb" emptypb "google.golang.org/protobuf/types/known/emptypb"
) )
@ -36,14 +38,25 @@ var DtmClient dtmgpb.DtmClient
// BusiCli grpc client for busi // BusiCli grpc client for busi
var BusiCli BusiClient var BusiCli BusiClient
func retry(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
logger.Debugf("in retry interceptor")
err := invoker(ctx, method, req, reply, cc, opts...)
if st, _ := status.FromError(err); st != nil && st.Code() == codes.Unavailable {
logger.Errorf("invoker return err: %v", err)
time.Sleep(1000 * time.Millisecond)
err = invoker(ctx, method, req, reply, cc, opts...)
}
return err
}
// GrpcStartup for grpc // GrpcStartup for grpc
func GrpcStartup() *grpc.Server { func GrpcStartup() *grpc.Server {
conn, err := grpc.Dial(dtmutil.DefaultGrpcServer, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(dtmgimp.GrpcClientLog)) conn, err := grpc.Dial(dtmutil.DefaultGrpcServer, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(dtmgimp.GrpcClientLog))
logger.FatalIfError(err) logger.FatalIfError(err)
DtmClient = dtmgpb.NewDtmClient(conn) DtmClient = dtmgpb.NewDtmClient(conn)
logger.Debugf("dtm client inited") logger.Debugf("dtm client inited")
// in github actions, the call is failed sometime, so add a retry
conn1, err := grpc.Dial(BusiGrpc, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(workflow.Interceptor)) conn1, err := grpc.Dial(BusiGrpc, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithChainUnaryInterceptor(workflow.Interceptor, retry))
logger.FatalIfError(err) logger.FatalIfError(err)
BusiCli = NewBusiClient(conn1) BusiCli = NewBusiClient(conn1)
@ -58,6 +71,7 @@ func RunGrpc(server *grpc.Server) {
logger.FatalIfError(err) logger.FatalIfError(err)
logger.Debugf("busi grpc listening at %v", lis.Addr()) logger.Debugf("busi grpc listening at %v", lis.Addr())
err = server.Serve(lis) err = server.Serve(lis)
logger.Errorf("grpc server serve return: %v", err)
logger.FatalIfError(err) logger.FatalIfError(err)
} }
@ -68,7 +82,7 @@ type busiServer struct {
func (s *busiServer) QueryPrepared(ctx context.Context, in *ReqGrpc) (*BusiReply, error) { func (s *busiServer) QueryPrepared(ctx context.Context, in *ReqGrpc) (*BusiReply, error) {
res := MainSwitch.QueryPreparedResult.Fetch() res := MainSwitch.QueryPreparedResult.Fetch()
err := dtmcli.String2DtmError(res) err := string2DtmError(res)
return &BusiReply{Message: "a sample data"}, dtmgrpc.DtmError2GrpcError(err) return &BusiReply{Message: "a sample data"}, dtmgrpc.DtmError2GrpcError(err)
} }

10
test/busi/base_http.go

@ -12,10 +12,10 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc/workflow" "github.com/dtm-labs/dtm/client/workflow"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
@ -125,7 +125,7 @@ func BaseAddRoute(app *gin.Engine) {
app.GET(BusiAPI+"/QueryPrepared", dtmutil.WrapHandler(func(c *gin.Context) interface{} { app.GET(BusiAPI+"/QueryPrepared", dtmutil.WrapHandler(func(c *gin.Context) interface{} {
logger.Debugf("%s QueryPrepared", c.Query("gid")) logger.Debugf("%s QueryPrepared", c.Query("gid"))
return dtmcli.String2DtmError(dtmimp.OrString(MainSwitch.QueryPreparedResult.Fetch(), dtmcli.ResultSuccess)) return string2DtmError(dtmimp.OrString(MainSwitch.QueryPreparedResult.Fetch(), dtmcli.ResultSuccess))
})) }))
app.GET(BusiAPI+"/QueryPreparedB", dtmutil.WrapHandler(func(c *gin.Context) interface{} { app.GET(BusiAPI+"/QueryPreparedB", dtmutil.WrapHandler(func(c *gin.Context) interface{} {
logger.Debugf("%s QueryPreparedB", c.Query("gid")) logger.Debugf("%s QueryPreparedB", c.Query("gid"))

4
test/busi/base_jrpc.go

@ -3,8 +3,8 @@ package busi
import ( import (
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

6
test/busi/base_types.go

@ -10,9 +10,9 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
) )

8
test/busi/data.go

@ -6,9 +6,9 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
@ -67,7 +67,7 @@ func handleGeneralBusiness(c *gin.Context, result1 string, result2 string, busi
if res == dtmimp.ResultFailure { if res == dtmimp.ResultFailure {
return fmt.Errorf("reason:%s. %w", MainSwitch.FailureReason.Fetch(), dtmimp.ErrFailure) return fmt.Errorf("reason:%s. %w", MainSwitch.FailureReason.Fetch(), dtmimp.ErrFailure)
} }
return dtmcli.String2DtmError(res) return string2DtmError(res)
} }
// old business handler. for compatible usage // old business handler. for compatible usage

2
test/busi/quick_start.go

@ -5,7 +5,7 @@ import (
"log" "log"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/lithammer/shortuuid/v3" "github.com/lithammer/shortuuid/v3"
) )

20
test/busi/utils.go

@ -9,11 +9,11 @@ import (
sync "sync" sync "sync"
"time" "time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/client/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmcli/logger" "github.com/dtm-labs/dtm/client/dtmcli/logger"
"github.com/dtm-labs/dtm/dtmgrpc" "github.com/dtm-labs/dtm/client/dtmgrpc"
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" "github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
@ -72,6 +72,16 @@ func MustBarrierFromGrpc(ctx context.Context) *dtmcli.BranchBarrier {
return ti return ti
} }
// string2DtmError translate string to dtm error
func string2DtmError(str string) error {
return map[string]error{
dtmcli.ResultFailure: dtmcli.ErrFailure,
dtmcli.ResultOngoing: dtmcli.ErrOngoing,
dtmcli.ResultSuccess: nil,
"": nil,
}[str]
}
// SetGrpcHeaderForHeadersYes interceptor to set head for HeadersYes // SetGrpcHeaderForHeadersYes interceptor to set head for HeadersYes
func SetGrpcHeaderForHeadersYes(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { func SetGrpcHeaderForHeadersYes(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
if r, ok := req.(*dtmgpb.DtmRequest); ok && strings.HasSuffix(r.Gid, "HeadersYes") { if r, ok := req.(*dtmgpb.DtmRequest); ok && strings.HasSuffix(r.Gid, "HeadersYes") {

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save