From 27ba89395fa4a50b1ad6ede5c5c044510a2debc2 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Fri, 15 Apr 2022 19:16:55 +0800 Subject: [PATCH] http microserice added to support springcloud alibaba --- conf.sample.yml | 20 +++++++++++++------- dtmsvr/trans_status.go | 5 ----- go.mod | 8 ++++---- go.sum | 4 ++++ main.go | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/conf.sample.yml b/conf.sample.yml index f3888f2..a6a24e9 100644 --- a/conf.sample.yml +++ b/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 diff --git a/dtmsvr/trans_status.go b/dtmsvr/trans_status.go index 51f0ecd..4319976 100644 --- a/dtmsvr/trans_status.go +++ b/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 diff --git a/go.mod b/go.mod index 0295cdb..4613dc8 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index f01200a..d387e33 100644 --- a/go.sum +++ b/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= diff --git a/main.go b/main.go index 44dcd71..e632169 100644 --- a/main.go +++ b/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