Browse Source

fix go lint

pull/313/head
xyctruth 4 years ago
parent
commit
d30daa959c
  1. 4
      dtmcli/dtmimp/utils.go
  2. 10
      dtmsvr/trans_status.go

4
dtmcli/dtmimp/utils.go

@ -233,8 +233,8 @@ func RespAsErrorCompatible(resp *resty.Response) error {
return nil return nil
} }
// JsonRpcRespAsError translate json rpc resty response to error // RespAsErrorByJSONRPC translate json rpc resty response to error
func JsonRpcRespAsError(resp *resty.Response) error { func RespAsErrorByJSONRPC(resp *resty.Response) error {
str := resp.String() str := resp.String()
var result map[string]interface{} var result map[string]interface{}
MustUnmarshalString(str, &result) MustUnmarshalString(str, &result)

10
dtmsvr/trans_status.go

@ -113,14 +113,14 @@ func (t *TransGlobal) getURLResult(uri string, branchID, op string, branchPayloa
dtmimp.RestyClient.SetTimeout(time.Duration(t.RequestTimeout) * time.Second) dtmimp.RestyClient.SetTimeout(time.Duration(t.RequestTimeout) * time.Second)
} }
if t.Protocol == "json-rpc" && strings.Contains(uri, "method") { if t.Protocol == "json-rpc" && strings.Contains(uri, "method") {
return t.getJsonRpcResult(uri, branchID, op, branchPayload) return t.getJSONRPCResult(uri, branchID, op, branchPayload)
} }
return t.getHttpResult(uri, branchID, op, branchPayload) return t.getHTTPResult(uri, branchID, op, branchPayload)
} }
return t.getGrpcResult(uri, branchID, op, branchPayload) return t.getGrpcResult(uri, branchID, op, branchPayload)
} }
func (t *TransGlobal) getHttpResult(uri string, branchID, op string, branchPayload []byte) error { func (t *TransGlobal) getHTTPResult(uri string, branchID, op string, branchPayload []byte) error {
resp, err := dtmimp.RestyClient.R().SetBody(string(branchPayload)). resp, err := dtmimp.RestyClient.R().SetBody(string(branchPayload)).
SetQueryParams(map[string]string{ SetQueryParams(map[string]string{
"gid": t.Gid, "gid": t.Gid,
@ -138,7 +138,7 @@ func (t *TransGlobal) getHttpResult(uri string, branchID, op string, branchPaylo
return dtmimp.RespAsErrorCompatible(resp) return dtmimp.RespAsErrorCompatible(resp)
} }
func (t *TransGlobal) getJsonRpcResult(uri string, branchID, op string, branchPayload []byte) error { func (t *TransGlobal) getJSONRPCResult(uri string, branchID, op string, branchPayload []byte) error {
var params map[string]interface{} var params map[string]interface{}
dtmimp.MustUnmarshal(branchPayload, &params) dtmimp.MustUnmarshal(branchPayload, &params)
u, err := url.Parse(uri) u, err := url.Parse(uri)
@ -161,7 +161,7 @@ func (t *TransGlobal) getJsonRpcResult(uri string, branchID, op string, branchPa
err = dtmimp.RespAsErrorCompatible(resp) err = dtmimp.RespAsErrorCompatible(resp)
} }
if err == nil { if err == nil {
err = dtmimp.JsonRpcRespAsError(resp) err = dtmimp.RespAsErrorByJSONRPC(resp)
} }
return err return err
} }

Loading…
Cancel
Save