diff --git a/dtmgrpc/dtmgimp/grpc_clients.go b/dtmgrpc/dtmgimp/grpc_clients.go index b299b9a..44e755b 100644 --- a/dtmgrpc/dtmgimp/grpc_clients.go +++ b/dtmgrpc/dtmgimp/grpc_clients.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 diff --git a/dtmgrpc/tcc.go b/dtmgrpc/tcc.go index 3f39676..0fd5b7d 100644 --- a/dtmgrpc/tcc.go +++ b/dtmgrpc/tcc.go @@ -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, diff --git a/dtmgrpc/type.go b/dtmgrpc/type.go index d166b5c..f900170 100644 --- a/dtmgrpc/type.go +++ b/dtmgrpc/type.go @@ -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) } diff --git a/main.go b/main.go index 013441d..1b088e1 100644 --- a/main.go +++ b/main.go @@ -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的定时过期查询