Skip to content
Snippets Groups Projects
Commit 175fe545 authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #1028 from cvictory/feature/getty_write_length

Fix: support getty send Length, when the data transfer failed 
parents 455ec49d 978b5390
No related branches found
No related tags found
No related merge requests found
...@@ -179,8 +179,21 @@ If you are willing to do some code contributions and document contributions to [ ...@@ -179,8 +179,21 @@ If you are willing to do some code contributions and document contributions to [
If u want to communicate with our community, pls scan the following [dubbobo Ding-Ding QR code](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1) or search our commnity DingDing group code 31363295. If u want to communicate with our community, pls scan the following [dubbobo Ding-Ding QR code](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1) or search our commnity DingDing group code 31363295.
<a href="http://alexstocks.github.io/html/dubbogo.html"> <div>
<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a> <table>
<tbody>
<tr></tr>
<tr>
<td align="center" valign="middle">
<a href="http://alexstocks.github.io/html/dubbogo.html" target="_blank">
<img width="80px" height="85px" src="./doc/pic/misc/dubbogo-dingding.png">
</a>
</td>
</tr>
<tr></tr>
</tbody>
</table>
</div>
If u want to visit the wechat group, pls add my wechat AlexanderStocks. If u want to visit the wechat group, pls add my wechat AlexanderStocks.
......
...@@ -177,12 +177,25 @@ make test ...@@ -177,12 +177,25 @@ make test
如果想访问官方钉钉群,请在钉钉中搜索社区群号 31363295 或者 扫描如下[二维码](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1) 如果想访问官方钉钉群,请在钉钉中搜索社区群号 31363295 或者 扫描如下[二维码](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1)
<a href="http://alexstocks.github.io/html/dubbogo.html"> <div>
<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a> <table>
<tbody>
<tr></tr>
<tr>
<td align="center" valign="middle">
<a href="http://alexstocks.github.io/html/dubbogo.html" target="_blank">
<img width="80px" height="85px" src="./doc/pic/misc/dubbogo-dingding.png">
</a>
</td>
</tr>
<tr></tr>
</tbody>
</table>
</div>
如果想加入到社区微信群,可以先添加社区负责人 于雨 的微信 AlexanderStocks 。 如果想加入到社区微信群,可以先添加社区负责人 于雨 的微信 AlexanderStocks 。添加微信之前,请先给 dubbo-go 点 star 作为对项目的支持,添加好友时请报上 github ID 以进行验证。
作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者。 作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者,只知索取者和喷子请绕行
## 性能测试 ## ## 性能测试 ##
......
...@@ -81,8 +81,8 @@ github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTr ...@@ -81,8 +81,8 @@ github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTr
github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI= github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 h1:zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA= github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 h1:zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
github.com/apache/dubbo-getty v1.4.1 h1:M9yaFhemThQSWtRwmJNrxNuv7FzydlFx5EY8oq1v+lw= github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI=
github.com/apache/dubbo-getty v1.4.1/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek=
github.com/apache/dubbo-go-hessian2 v1.8.2 h1:CQq2Mmlrk6Fqmudwl9Dqps8drTrBFnmXRlzgOjj0FqA= github.com/apache/dubbo-go-hessian2 v1.8.2 h1:CQq2Mmlrk6Fqmudwl9Dqps8drTrBFnmXRlzgOjj0FqA=
github.com/apache/dubbo-go-hessian2 v1.8.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.8.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
......
...@@ -181,8 +181,15 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo ...@@ -181,8 +181,15 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo
if session == nil { if session == nil {
return errSessionNotExist return errSessionNotExist
} }
var (
if err = c.transfer(session, request, timeout); err != nil { totalLen int
sendLen int
)
if totalLen, sendLen, err = c.transfer(session, request, timeout); err != nil {
if sendLen != 0 && totalLen != sendLen {
logger.Warnf("start to close the session at request because %d of %d bytes data is sent success. err:%+v", sendLen, totalLen, err)
go c.Close()
}
return perrors.WithStack(err) return perrors.WithStack(err)
} }
...@@ -221,7 +228,7 @@ func (c *Client) selectSession(addr string) (*gettyRPCClient, getty.Session, err ...@@ -221,7 +228,7 @@ func (c *Client) selectSession(addr string) (*gettyRPCClient, getty.Session, err
return rpcClient, rpcClient.selectSession(), nil return rpcClient, rpcClient.selectSession(), nil
} }
func (c *Client) transfer(session getty.Session, request *remoting.Request, timeout time.Duration) error { func (c *Client) transfer(session getty.Session, request *remoting.Request, timeout time.Duration) (int, int, error) {
err := session.WritePkg(request, timeout) totalLen, sendLen, err := session.WritePkg(request, timeout)
return perrors.WithStack(err) return totalLen, sendLen, perrors.WithStack(err)
} }
...@@ -355,7 +355,11 @@ func (h *RpcServerHandler) OnCron(session getty.Session) { ...@@ -355,7 +355,11 @@ func (h *RpcServerHandler) OnCron(session getty.Session) {
} }
func reply(session getty.Session, resp *remoting.Response) { func reply(session getty.Session, resp *remoting.Response) {
if err := session.WritePkg(resp, WritePkg_Timeout); err != nil { if totalLen, sendLen, err := session.WritePkg(resp, WritePkg_Timeout); err != nil {
if sendLen != 0 && totalLen != sendLen {
logger.Warnf("start to close the session at replying because %d of %d bytes data is sent success. err:%+v", sendLen, totalLen, err)
go session.Close()
}
logger.Errorf("WritePkg error: %#v, %#v", perrors.WithStack(err), resp) logger.Errorf("WritePkg error: %#v, %#v", perrors.WithStack(err), resp)
} }
} }
...@@ -366,7 +370,11 @@ func heartbeat(session getty.Session, timeout time.Duration, callBack func(err e ...@@ -366,7 +370,11 @@ func heartbeat(session getty.Session, timeout time.Duration, callBack func(err e
req.Event = true req.Event = true
resp := remoting.NewPendingResponse(req.ID) resp := remoting.NewPendingResponse(req.ID)
remoting.AddPendingResponse(resp) remoting.AddPendingResponse(resp)
err := session.WritePkg(req, 3*time.Second) totalLen, sendLen, err := session.WritePkg(req, 3*time.Second)
if sendLen != 0 && totalLen != sendLen {
logger.Warnf("start to close the session at heartbeat because %d of %d bytes data is sent success. err:%+v", sendLen, totalLen, err)
go session.Close()
}
go func() { go func() {
var err1 error var err1 error
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment