[ISSUE #366] feat: remove extra code (#367)
* feat: remove extra code
Closes #366
* fix
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 @@
import (
"context"
"sync"
- "time"
"github.com/apache/rocketmq-client-go/internal/utils"
)
@@ -28,11 +27,9 @@
// 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 @@
// 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 @@
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 @@
if err != nil {
return nil, err
}
- resp.SendRequestOK = true
return resp.waitResponse()
}
@@ -96,7 +95,6 @@
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 @@
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)
}