This is an automated email from the ASF dual-hosted git repository.
wenfeng pushed a commit to branch native
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git
The following commit(s) were added to refs/heads/native by this push:
new 4c3fa1c [ISSUE #366] feat: remove extra code (#367)
4c3fa1c is described below
commit 4c3fa1ca88c777f222d88ba2e0eaabcdb0d72436
Author: xujianhai666 <[email protected]>
AuthorDate: Mon Jan 6 10:04:01 2020 +0800
[ISSUE #366] feat: remove extra code (#367)
* feat: remove extra code
Closes #366
* fix
---
internal/remote/future.go | 29 ++++++++++-------------------
internal/remote/remote_client.go | 2 --
internal/remote/remote_client_test.go | 3 ---
3 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/internal/remote/future.go b/internal/remote/future.go
index 5a83d6f..cba210e 100644
--- a/internal/remote/future.go
+++ b/internal/remote/future.go
@@ -20,7 +20,6 @@ package remote
import (
"context"
"sync"
- "time"
"github.com/apache/rocketmq-client-go/internal/utils"
)
@@ -28,11 +27,9 @@ import (
// ResponseFuture
type ResponseFuture struct {
ResponseCommand *RemotingCommand
- SendRequestOK bool
Err error
Opaque int32
callback func(*ResponseFuture)
- BeginTimestamp time.Duration
Done chan bool
callbackOnce sync.Once
ctx context.Context
@@ -41,11 +38,10 @@ type ResponseFuture struct {
// NewResponseFuture create ResponseFuture with opaque, timeout and callback
func NewResponseFuture(ctx context.Context, opaque int32, callback
func(*ResponseFuture)) *ResponseFuture {
return &ResponseFuture{
- Opaque: opaque,
- Done: make(chan bool),
- callback: callback,
- BeginTimestamp: time.Duration(time.Now().Unix()) * time.Second,
- ctx: ctx,
+ Opaque: opaque,
+ Done: make(chan bool),
+ callback: callback,
+ ctx: ctx,
}
}
@@ -62,17 +58,12 @@ func (r *ResponseFuture) waitResponse() (*RemotingCommand,
error) {
cmd *RemotingCommand
err error
)
- for {
- select {
- case <-r.Done:
- cmd, err = r.ResponseCommand, r.Err
- goto done
- case <-r.ctx.Done():
- err = utils.ErrRequestTimeout
- r.Err = err
- goto done
- }
+ select {
+ case <-r.Done:
+ cmd, err = r.ResponseCommand, r.Err
+ case <-r.ctx.Done():
+ err = utils.ErrRequestTimeout
+ r.Err = err
}
-done:
return cmd, err
}
diff --git a/internal/remote/remote_client.go b/internal/remote/remote_client.go
index b5ad436..3d2bf7f 100644
--- a/internal/remote/remote_client.go
+++ b/internal/remote/remote_client.go
@@ -80,7 +80,6 @@ func (c *remotingClient) InvokeSync(ctx context.Context, addr
string, request *R
if err != nil {
return nil, err
}
- resp.SendRequestOK = true
return resp.waitResponse()
}
@@ -96,7 +95,6 @@ func (c *remotingClient) InvokeAsync(ctx context.Context,
addr string, request *
if err != nil {
return err
}
- resp.SendRequestOK = true
go c.receiveAsync(resp)
return nil
}
diff --git a/internal/remote/remote_client_test.go
b/internal/remote/remote_client_test.go
index f3aa6a2..bd53e65 100644
--- a/internal/remote/remote_client_test.go
+++ b/internal/remote/remote_client_test.go
@@ -37,9 +37,6 @@ func TestNewResponseFuture(t *testing.T) {
if future.Opaque != 10 {
t.Errorf("wrong ResponseFuture's opaque. want=%d, got=%d", 10,
future.Opaque)
}
- if future.SendRequestOK != false {
- t.Errorf("wrong ResposneFutrue's sendRequestOK. want=%t,
got=%t", false, future.SendRequestOK)
- }
if future.Err != nil {
t.Errorf("wrong RespnseFuture's Err. want=<nil>, got=%v",
future.Err)
}