Browse Source

http microserice added to support springcloud alibaba

pull/262/head
yedf2 4 years ago
parent
commit
27ba89395f
  1. 20
      conf.sample.yml
  2. 5
      dtmsvr/trans_status.go
  3. 8
      go.mod
  4. 4
      go.sum
  5. 2
      main.go

20
conf.sample.yml

@ -37,13 +37,19 @@
# SuccessDataExpire: 86400 # successful Trans data will expire in 1 days. only for redis.
# RedisPrefix: '{a}' # default value is '{a}'. Redis storage prefix. store data to only one slot in cluster
HttpMicroService:
Driver: 'dtm-driver-http'
RegistryType: 'nacos'
RegistryAddress: '127.0.0.1:8848,127.0.0.1:8848'
RegistryOptions: '{"UserName":"nacos","Password":"nacos","NotLoadCacheAtStart":true}'
Target: '{"ServiceName":"dtmService","Enable":true,"Healthy":true,"Weight":10}'
EndPoint: '127.0.0.1:36789'
# MicroService: # grpc based microservice config
# Driver: 'dtm-driver-gozero' # name of the driver to handle register/discover
# Target: 'etcd://localhost:2379/dtmservice' # register dtm server to this url
# EndPoint: 'localhost:36790'
# HttpMicroService: # http based microservice config
# Driver: 'dtm-driver-http' # name of the driver to handle register/discover
# RegistryType: 'nacos'
# RegistryAddress: '127.0.0.1:8848,127.0.0.1:8848'
# RegistryOptions: '{"UserName":"nacos","Password":"nacos","NotLoadCacheAtStart":true}'
# Target: '{"ServiceName":"dtmService","Enable":true,"Healthy":true,"Weight":10}' # target and options
# EndPoint: '127.0.0.1:36789'
### the unit of following configurations is second
# TransCronInterval: 3 # the interval to poll unfinished global transaction for every dtm process
# TimeoutToFail: 35 # timeout for XA, TCC to fail. saga's timeout default to infinite, which can be overwritten in saga options

5
dtmsvr/trans_status.go

@ -9,7 +9,6 @@ package dtmsvr
import (
"errors"
"fmt"
"github.com/horseLk/dtmdriver-nacos/httpdriver"
"net/url"
"strings"
"time"
@ -175,10 +174,6 @@ func (t *TransGlobal) getURLResult(uri string, branchID, op string, branchPayloa
func (t *TransGlobal) getBranchResult(branch *TransBranch) (string, error) {
realUrl := branch.URL
// resolver http url.
if v, ok := dtmdriver.GetDriver().(httpdriver.HttpDriver); ok {
realUrl = v.ResolveHttpService(branch.URL)
}
err := t.getURLResult(realUrl, branch.BranchID, branch.Op, branch.BinData)
if err == nil {
return dtmcli.StatusSucceed, nil

8
go.mod

@ -5,8 +5,9 @@ go 1.16
require (
bou.ke/monkey v1.0.2
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/dtm-labs/dtmdriver v0.0.1
github.com/dtm-labs/dtmdriver v0.0.2
github.com/dtm-labs/dtmdriver-gozero v0.0.2
github.com/dtm-labs/dtmdriver-http v1.2.0
github.com/dtm-labs/dtmdriver-kratos v0.0.4
github.com/dtm-labs/dtmdriver-polaris v0.0.4
github.com/dtm-labs/dtmdriver-protocol1 v0.0.1
@ -14,7 +15,6 @@ 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.1.0
github.com/lib/pq v1.10.4
github.com/lithammer/shortuuid v2.0.3+incompatible
github.com/lithammer/shortuuid/v3 v3.0.7
@ -36,6 +36,6 @@ require (
// gotest.tools v2.2.0+incompatible
)
replace github.com/dtm-labs/dtmdriver v0.0.1 => /Users/wangxi/dtm/dtmdriver
// replace github.com/dtm-labs/dtmdriver v0.0.1 => /Users/wangxi/dtm/dtmdriver
replace github.com/horseLk/dtmdriver-nacos v1.1.0 => /Users/wangxi/dtm/dtmdriver-http-nacos
// replace github.com/horseLk/dtmdriver-nacos v1.1.0 => /Users/wangxi/dtm/dtmdriver-http-nacos

4
go.sum

@ -109,8 +109,12 @@ github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZ
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dtm-labs/dtmdriver v0.0.1 h1:dHUZQ6g2ZN6eRUqds9kKq/3K7u9bcUGatUlbthD92fA=
github.com/dtm-labs/dtmdriver v0.0.1/go.mod h1:fLiEeD2BPwM9Yq96TfcP9KpbTwFsn5nTxa/PP0jmFuk=
github.com/dtm-labs/dtmdriver v0.0.2 h1:h2lbxPiUe2T3RwkbO108khgUXIwZpxMw/4a2u4Df+z8=
github.com/dtm-labs/dtmdriver v0.0.2/go.mod h1:fLiEeD2BPwM9Yq96TfcP9KpbTwFsn5nTxa/PP0jmFuk=
github.com/dtm-labs/dtmdriver-gozero v0.0.2 h1:T+JH9kwVNMmISPU1BNviiTrvPdMA7UMFD+nfTqGPSyA=
github.com/dtm-labs/dtmdriver-gozero v0.0.2/go.mod h1:5AAKwYok5f56e0kATOXvc+DAsfu4elISDuCV+G3+fYE=
github.com/dtm-labs/dtmdriver-http v1.2.0 h1:9v1od77rSrJUuiBnZ/o6Ic4jRJpToxjP2nUOnx9CIas=
github.com/dtm-labs/dtmdriver-http v1.2.0/go.mod h1:UtWShS61TiiudZUAabQ2ww0CzSEpBYF3AS3F3G2Jc2o=
github.com/dtm-labs/dtmdriver-kratos v0.0.4 h1:jDVvrwiw8GwVrampIxhoXZ9TewwQKHFpcDcQXyU2Qyc=
github.com/dtm-labs/dtmdriver-kratos v0.0.4/go.mod h1:MjrFIa2A191ATVb/xy2vnA2ZKqMK9zC/1m3pjxXwkac=
github.com/dtm-labs/dtmdriver-polaris v0.0.4 h1:yli0YmAsEgl47ymJHTxIzULeNe5dnmfN2ixLJRWm2Ok=

2
main.go

@ -21,10 +21,10 @@ import (
// load the microserver driver
_ "github.com/dtm-labs/dtmdriver-gozero"
_ "github.com/dtm-labs/dtmdriver-http"
_ "github.com/dtm-labs/dtmdriver-kratos"
_ "github.com/dtm-labs/dtmdriver-polaris"
_ "github.com/dtm-labs/dtmdriver-protocol1"
_ "github.com/horseLk/dtmdriver-nacos"
)
// Version declares version info

Loading…
Cancel
Save