Browse Source
Merge pull request #267 from dtm-labs/alpha
Update dtmdriver-http
pull/268/head
yedf2
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
13 additions and
7 deletions
-
dtmcli/dtmimp/consts.go
-
dtmcli/dtmimp/vars.go
-
dtmsvr/trans_class.go
-
dtmsvr/trans_status.go
-
go.mod
-
go.sum
|
|
|
@ -55,4 +55,9 @@ const ( |
|
|
|
|
|
|
|
// XaBarrier1 const for xa barrier id
|
|
|
|
XaBarrier1 = "01" |
|
|
|
|
|
|
|
// ProtocolGRPC const for protocol grpc
|
|
|
|
ProtocolGRPC = "grpc" |
|
|
|
// ProtocolHTTP const for protocol http
|
|
|
|
ProtocolHTTP = "http" |
|
|
|
) |
|
|
|
|
|
|
|
@ -46,9 +46,8 @@ func init() { |
|
|
|
RestyClient.OnBeforeRequest(func(c *resty.Client, r *resty.Request) error { |
|
|
|
r.URL = MayReplaceLocalhost(r.URL) |
|
|
|
u, err := dtmdriver.GetHTTPDriver().ResolveURL(r.URL) |
|
|
|
logger.Debugf("requesting: %s %s %s", r.Method, r.URL, MustMarshalString(r.Body)) |
|
|
|
logger.Debugf("requesting: %s %s %s resolved: %s", r.Method, r.URL, MustMarshalString(r.Body), u) |
|
|
|
r.URL = u |
|
|
|
logger.Debugf("resolved: %s err: %v", r.URL, err) |
|
|
|
return err |
|
|
|
}) |
|
|
|
RestyClient.OnAfterResponse(func(c *resty.Client, resp *resty.Response) error { |
|
|
|
|
|
|
|
@ -31,7 +31,7 @@ func (t *TransGlobal) setupPayloads() { |
|
|
|
} |
|
|
|
} |
|
|
|
if t.Protocol == "" { |
|
|
|
t.Protocol = "http" |
|
|
|
t.Protocol = dtmimp.ProtocolHTTP |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -89,7 +89,7 @@ func (t *TransGlobal) getURLResult(uri string, branchID, op string, branchPayloa |
|
|
|
if uri == "" { // empty url is success
|
|
|
|
return nil |
|
|
|
} |
|
|
|
if strings.HasPrefix(uri, "http://") || strings.HasPrefix(uri, "https://") { |
|
|
|
if t.Protocol == dtmimp.ProtocolHTTP || strings.HasPrefix(uri, "http://") || strings.HasPrefix(uri, "https://") { |
|
|
|
if t.RequestTimeout != 0 { |
|
|
|
dtmimp.RestyClient.SetTimeout(time.Duration(t.RequestTimeout) * time.Second) |
|
|
|
} |
|
|
|
@ -146,7 +146,7 @@ func (t *TransGlobal) getURLResult(uri string, branchID, op string, branchPayloa |
|
|
|
} |
|
|
|
return dtmimp.RespAsErrorCompatible(resp) |
|
|
|
} |
|
|
|
dtmimp.PanicIf(t.Protocol == "http", fmt.Errorf("bad url for http: %s", uri)) |
|
|
|
dtmimp.PanicIf(t.Protocol == dtmimp.ProtocolHTTP, fmt.Errorf("bad url for http: %s", uri)) |
|
|
|
// grpc handler
|
|
|
|
server, method, err := dtmdriver.GetDriver().ParseServerMethod(uri) |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
@ -7,7 +7,7 @@ require ( |
|
|
|
github.com/BurntSushi/toml v0.4.1 // indirect |
|
|
|
github.com/dtm-labs/dtmdriver v0.0.3 |
|
|
|
github.com/dtm-labs/dtmdriver-gozero v0.0.2 |
|
|
|
github.com/dtm-labs/dtmdriver-http v1.2.0 |
|
|
|
github.com/dtm-labs/dtmdriver-http v1.2.2 |
|
|
|
github.com/dtm-labs/dtmdriver-kratos v0.0.8 |
|
|
|
github.com/dtm-labs/dtmdriver-polaris v0.0.4 |
|
|
|
github.com/dtm-labs/dtmdriver-protocol1 v0.0.1 |
|
|
|
@ -38,4 +38,4 @@ require ( |
|
|
|
|
|
|
|
// replace github.com/dtm-labs/dtmdriver v0.0.2 => /Users/wangxi/dtm/dtmdriver |
|
|
|
|
|
|
|
// replace github.com/horseLk/dtmdriver-nacos v1.1.0 => /Users/wangxi/dtm/dtmdriver-http-nacos |
|
|
|
// replace github.com/dtm-labs/dtmdriver-http => /Users/wangxi/dtm/dtmdriver-http-nacos |
|
|
|
|
|
|
|
@ -127,6 +127,8 @@ github.com/dtm-labs/dtmdriver-gozero v0.0.2 h1:T+JH9kwVNMmISPU1BNviiTrvPdMA7UMFD |
|
|
|
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-http v1.2.2 h1:QOul+PpK1KQyXXx5viNrHrEFIc/nFxmX4fJfI3DLUqI= |
|
|
|
github.com/dtm-labs/dtmdriver-http v1.2.2/go.mod h1:UtWShS61TiiudZUAabQ2ww0CzSEpBYF3AS3F3G2Jc2o= |
|
|
|
github.com/dtm-labs/dtmdriver-kratos v0.0.8 h1:AAIfFzpzuu7K3B/wpx71y0FdZqO1X/Bsklva0bayS9s= |
|
|
|
github.com/dtm-labs/dtmdriver-kratos v0.0.8/go.mod h1:MlREYO7d7Ocbs4NsuU/LQMBBcHix6rubjW+in2hNRyk= |
|
|
|
github.com/dtm-labs/dtmdriver-polaris v0.0.4 h1:yli0YmAsEgl47ymJHTxIzULeNe5dnmfN2ixLJRWm2Ok= |
|
|
|
|