Browse Source
Merge pull request #169 from Leizhengzi/main
fix: dtmgrpc relevant golangci lint error
pull/173/head
yedf2
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
9 additions and
4 deletions
-
dtmgrpc/dtmgimp/grpc_clients.go
-
dtmgrpc/tcc.go
-
dtmgrpc/type.go
-
main.go
|
|
|
@ -26,9 +26,8 @@ func (cb rawCodec) Marshal(v interface{}) ([]byte, error) { |
|
|
|
func (cb rawCodec) Unmarshal(data []byte, v interface{}) error { |
|
|
|
ba, ok := v.(*[]byte) |
|
|
|
dtmimp.PanicIf(!ok, fmt.Errorf("please pass in *[]byte")) |
|
|
|
for _, byte := range data { |
|
|
|
*ba = append(*ba, byte) |
|
|
|
} |
|
|
|
*ba = append(*ba, data...) |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
@ -36,6 +35,7 @@ func (cb rawCodec) Name() string { return "dtm_raw" } |
|
|
|
|
|
|
|
var normalClients, rawClients sync.Map |
|
|
|
|
|
|
|
// ClientInterceptors declares grpc.UnaryClientInterceptors slice
|
|
|
|
var ClientInterceptors = []grpc.UnaryClientInterceptor{} |
|
|
|
|
|
|
|
// MustGetDtmClient 1
|
|
|
|
|
|
|
|
@ -75,6 +75,9 @@ func TccFromGrpc(ctx context.Context) (*TccGrpc, error) { |
|
|
|
func (t *TccGrpc) CallBranch(busiMsg proto.Message, tryURL string, confirmURL string, cancelURL string, reply interface{}) error { |
|
|
|
branchID := t.NewSubBranchID() |
|
|
|
bd, err := proto.Marshal(busiMsg) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
_, err = dtmgimp.MustGetDtmClient(t.Dtm).RegisterBranch(context.Background(), &dtmgpb.DtmBranchRequest{ |
|
|
|
Gid: t.Gid, |
|
|
|
TransType: t.TransType, |
|
|
|
|
|
|
|
@ -29,6 +29,7 @@ func UseDriver(driverName string) error { |
|
|
|
return dtmdriver.Use(driverName) |
|
|
|
} |
|
|
|
|
|
|
|
// AddUnaryInterceptor adds grpc.UnaryClientInterceptor
|
|
|
|
func AddUnaryInterceptor(interceptor grpc.UnaryClientInterceptor) { |
|
|
|
dtmgimp.ClientInterceptors = append(dtmgimp.ClientInterceptors, interceptor) |
|
|
|
} |
|
|
|
|
|
|
|
@ -25,6 +25,7 @@ import ( |
|
|
|
_ "github.com/dtm-labs/dtmdriver-protocol1" |
|
|
|
) |
|
|
|
|
|
|
|
// Version declares version info
|
|
|
|
var Version string |
|
|
|
|
|
|
|
func version() { |
|
|
|
@ -63,7 +64,7 @@ func main() { |
|
|
|
if *isReset { |
|
|
|
dtmsvr.PopulateDB(false) |
|
|
|
} |
|
|
|
maxprocs.Set(maxprocs.Logger(logger.Infof)) |
|
|
|
_, _ = maxprocs.Set(maxprocs.Logger(logger.Infof)) |
|
|
|
registry.WaitStoreUp() |
|
|
|
dtmsvr.StartSvr() // 启动dtmsvr的api服务
|
|
|
|
go dtmsvr.CronExpiredTrans(-1) // 启动dtmsvr的定时过期查询
|
|
|
|
|