Skip to content

Commit

Permalink
modify async response with buffered channel
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemalin committed Aug 12, 2021
1 parent 7e6983c commit 0a81ec1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (c *RpcClient) SendRpcRequestWithTimeout(timeout time.Duration, rpcInvocati

var rsp *RpcDataPackage
if c.asyncMode {
ch := make(chan *RpcDataPackage)
ch := make(chan *RpcDataPackage, 1)
c.requestCallState[correlationId] = ch

if timeout > 0 {
Expand All @@ -321,7 +321,7 @@ func (c *RpcClient) SendRpcRequestWithTimeout(timeout time.Duration, rpcInvocati

} else {
if timeout > 0 {
ch := make(chan *RpcDataPackage)
ch := make(chan *RpcDataPackage, 1)
go c.asyncRequest(timeout, rpcDataPackage, ch)
defer close(ch)
// wait for message
Expand Down

0 comments on commit 0a81ec1

Please sign in to comment.