Skip to content

Commit

Permalink
fix(client): fix oneway seqid and lower loss rate
Browse files Browse the repository at this point in the history
  • Loading branch information
lsjbd committed Feb 25, 2022
1 parent da52b2c commit 11aeaaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/remote/codec/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func SetOrCheckMethodName(methodName string, message remote.Message) error {
// SetOrCheckSeqID is used to check the sequence ID.
func SetOrCheckSeqID(seqID int32, message remote.Message) error {
switch message.MessageType() {
case remote.Call:
case remote.Call, remote.Oneway:
if ink, ok := message.RPCInfo().Invocation().(rpcinfo.InvocationSetter); ok {
ink.SetSeqID(seqID)
} else {
Expand Down
5 changes: 5 additions & 0 deletions pkg/remote/remotecli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"net"
"sync"
"time"

"github.com/cloudwego/kitex/pkg/kerrors"
"github.com/cloudwego/kitex/pkg/remote"
Expand Down Expand Up @@ -98,6 +99,10 @@ func (c *client) Recv(ctx context.Context, ri rpcinfo.RPCInfo, resp remote.Messa
if resp != nil {
err = c.transHdlr.Read(ctx, c.conn, resp)
c.transHdlr.OnMessage(ctx, nil, resp)
} else {
// Wait for the request to be flushed out before closing the connection.
// 500us is an acceptable duration to keep a minimal loss rate at best effort.
time.Sleep(time.Millisecond / 2)
}

c.connManager.ReleaseConn(err, ri)
Expand Down

0 comments on commit 11aeaaa

Please sign in to comment.