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
parent
commit
c08813b2c6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dtmgrpc/dtmgimp/grpc_clients.go
  2. 3
      dtmgrpc/tcc.go
  3. 1
      dtmgrpc/type.go
  4. 3
      main.go

6
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

3
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,

1
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)
}

3
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的定时过期查询

Loading…
Cancel
Save