Skip to content

Commit

Permalink
Merge pull request #1028 from cvictory/feature/getty_write_length
Browse files Browse the repository at this point in the history
Fix: support getty send Length, when the data transfer failed
  • Loading branch information
AlexStocks authored Feb 2, 2021
2 parents 455ec49 + 978b539 commit 175fe54
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 16 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<a href="http://alexstocks.github.io/html/dubbogo.html">
<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a>
<div>
<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.

Expand Down
21 changes: 17 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<a href="http://alexstocks.github.io/html/dubbogo.html">
<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a>
<div>
<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 以进行验证。

作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者。
作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者,只知索取者和喷子请绕行

## 性能测试 ##

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Workiva/go-datastructures v1.0.52
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/alibaba/sentinel-golang v1.0.2
github.com/apache/dubbo-getty v1.4.1
github.com/apache/dubbo-getty v1.4.3
github.com/apache/dubbo-go-hessian2 v1.8.2
github.com/coreos/etcd v3.3.25+incompatible
github.com/creasty/defaults v1.5.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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/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/apache/dubbo-getty v1.4.1 h1:M9yaFhemThQSWtRwmJNrxNuv7FzydlFx5EY8oq1v+lw=
github.com/apache/dubbo-getty v1.4.1/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek=
github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI=
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/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
Expand Down
17 changes: 12 additions & 5 deletions remoting/getty/getty_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo
if session == nil {
return errSessionNotExist
}

if err = c.transfer(session, request, timeout); err != nil {
var (
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)
}

Expand Down Expand Up @@ -221,7 +228,7 @@ func (c *Client) selectSession(addr string) (*gettyRPCClient, getty.Session, err
return rpcClient, rpcClient.selectSession(), nil
}

func (c *Client) transfer(session getty.Session, request *remoting.Request, timeout time.Duration) error {
err := session.WritePkg(request, timeout)
return perrors.WithStack(err)
func (c *Client) transfer(session getty.Session, request *remoting.Request, timeout time.Duration) (int, int, error) {
totalLen, sendLen, err := session.WritePkg(request, timeout)
return totalLen, sendLen, perrors.WithStack(err)
}
12 changes: 10 additions & 2 deletions remoting/getty/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ func (h *RpcServerHandler) OnCron(session getty.Session) {
}

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)
}
}
Expand All @@ -366,7 +370,11 @@ func heartbeat(session getty.Session, timeout time.Duration, callBack func(err e
req.Event = true
resp := remoting.NewPendingResponse(req.ID)
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() {
var err1 error
Expand Down

0 comments on commit 175fe54

Please sign in to comment.