Browse Source

update resolver

pull/262/head
KuiLiao 4 years ago
parent
commit
2fae679606
  1. 2
      dtmsvr/svr.go
  2. 13
      dtmsvr/trans_status.go
  3. 2
      go.mod
  4. 2
      go.sum

2
dtmsvr/svr.go

@ -88,7 +88,7 @@ func StartSvr() {
for _, routeInfo := range routesInfo {
paths = append(paths, routeInfo.Path)
}
err = v.RegisterHttpService(conf.MicroService.Target, conf.MicroService.EndPoint, options, paths)
err = v.RegisterHttpService(conf.MicroService.Target, conf.MicroService.EndPoint, options)
} else {
logger.Infof("RegisterGrpcService: %s", conf.MicroService.Driver)
err = dtmdriver.GetDriver().RegisterGrpcService(conf.MicroService.Target, conf.MicroService.EndPoint)

13
dtmsvr/trans_status.go

@ -9,6 +9,7 @@ package dtmsvr
import (
"errors"
"fmt"
"github.com/horseLk/dtmdriver-nacos/httpdriver"
"net/url"
"strings"
"time"
@ -173,7 +174,17 @@ func (t *TransGlobal) getURLResult(uri string, branchID, op string, branchPayloa
}
func (t *TransGlobal) getBranchResult(branch *TransBranch) (string, error) {
err := t.getURLResult(branch.URL, branch.BranchID, branch.Op, branch.BinData)
branchUrl := branch.URL
// means use http driver, must resolve url
if strings.HasPrefix(branchUrl, dtmdriver.GetDriver().GetName()) {
curDriver := dtmdriver.GetDriver().(httpdriver.HttpDriver)
realUrl, err := curDriver.ResolveHttpService(branchUrl)
if err != nil {
return dtmcli.StatusFailed, err
}
branchUrl = realUrl
}
err := t.getURLResult(branchUrl, branch.BranchID, branch.Op, branch.BinData)
if err == nil {
return dtmcli.StatusSucceed, nil
} else if t.TransType == "saga" && branch.Op == dtmimp.OpAction && errors.Is(err, dtmcli.ErrFailure) {

2
go.mod

@ -14,7 +14,7 @@ require (
github.com/go-redis/redis/v8 v8.11.4
github.com/go-resty/resty/v2 v2.7.0
github.com/go-sql-driver/mysql v1.6.0
github.com/horseLk/dtmdriver-nacos v1.0.5
github.com/horseLk/dtmdriver-nacos v1.0.6
github.com/lib/pq v1.10.4
github.com/lithammer/shortuuid v2.0.3+incompatible
github.com/lithammer/shortuuid/v3 v3.0.7

2
go.sum

@ -299,6 +299,8 @@ github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/horseLk/dtmdriver-nacos v1.0.5 h1:M6RGpRHSOObkOl2KdIEfWbQCwsJI6OGJXvcWuozKMiY=
github.com/horseLk/dtmdriver-nacos v1.0.5/go.mod h1:sLy9zEQ50isWNDbcxOXf50+PBdYfRTUpA4MUsr0uhPQ=
github.com/horseLk/dtmdriver-nacos v1.0.6 h1:u9Zxap0Q/w3DtoUyeLaalGn1MaMl7tD+ttAs7uSwYns=
github.com/horseLk/dtmdriver-nacos v1.0.6/go.mod h1:sLy9zEQ50isWNDbcxOXf50+PBdYfRTUpA4MUsr0uhPQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=

Loading…
Cancel
Save