pherzheyu commented on code in PR #71:
URL: https://github.com/apache/rocketmq-clients/pull/71#discussion_r927218297


##########
golang/producer.go:
##########
@@ -157,40 +213,40 @@ func (p *producer) send1(ctx context.Context, topic 
string, messageType v2.Messa
        var res []*SendReceipt
        for i := 0; i < len(resp.GetEntries()); i++ {
                res = append(res, &SendReceipt{
-                       MessageID: resp.GetEntries()[i].GetMessageId(),
+                       MessageID:     resp.GetEntries()[i].GetMessageId(),
+                       TransactionId: resp.GetEntries()[i].GetTransactionId(),
+                       Offset:        resp.GetEntries()[i].GetOffset(),
+                       Endpoints:     endpoints,
                })
        }
        if attempt > 1 {
                log.Printf("Resend message successfully, topic=%s, 
maxAttempts=%d, attempt=%d, endpoints=%s, clientId=%s",
                        topic, maxAttempts, attempt, endpoints.String(), 
p.cli.clientID)
        }
        return res, nil
-       // sendRequest := b.getSendMessageRequest(msg)
-
-       // b, err := p.ns.GetBroker(ctx, msg.Topic)
-       // if err != nil {
-       //      return nil, err
-       // }
-       // return b.Send(ctx, msg)
-
-       // return nil, nil
 }
 
 // TODO refer to java sdk.
-func (p *producer) send0(ctx context.Context, msgs []*Message, txEnabled bool) 
([]*SendReceipt, error) {

Review Comment:
   send0可读性感觉不太好,最好是所见即所得,golang中没有重载,可以使用选项模式



##########
golang/message.go:
##########
@@ -17,41 +17,317 @@
 
 package golang
 
-import "time"
+import (
+       "crypto/md5"
+       "crypto/sha1"
+       "encoding/hex"
+       "hash/crc32"
+       "log"
+       "strconv"
+       "time"
+
+       v2 "github.com/apache/rocketmq-clients/golang/protocol/v2"
+       "github.com/apache/rocketmq-clients/golang/utils"
+       "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+type UnifiedMessage struct {
+       msg    *Message
+       pubMsg *PublishingMessage
+}
+
+func (uMsg *UnifiedMessage) GetMessage() *Message {
+       if uMsg.pubMsg != nil {
+               return uMsg.pubMsg.msg
+       }
+       return uMsg.msg
+}
 
 type Message struct {
-       Topic      string
-       Body       []byte
-       Tag        string
-       Keys       []string
-       Properties map[string]string
+       Topic        string
+       Body         []byte
+       Tag          *string
+       messageGroup *string
+       keys         []string
+       properties   map[string]string
 
-       deliveryTimestamp time.Time
-       messageGroup      string
+       deliveryTimestamp  *time.Time
+       parentTraceContext *string
 }
 
-type MessageExt struct {
+type SendReceipt struct {
        MessageID     string
-       ReceiptHandle string
-       Message
+       TransactionId string
+       Offset        int64
+       Endpoints     *v2.Endpoints
 }
 
-type SendReceipt struct {
-       MessageID string
+func (msg *Message) GetTopic() string {

Review Comment:
   字段大些,已经是可导出了,不用在增加额外的set、get



##########
golang/client_manager.go:
##########
@@ -162,31 +164,58 @@ func (cm *clientManagerImpl) startUp() {
 }
 func (cm *clientManagerImpl) clearIdleRpcClients() {
        log.Println("clearIdleRpcClients")

Review Comment:
   TODO:可以借助conn的logger



##########
golang/client_manager.go:
##########
@@ -162,31 +164,58 @@ func (cm *clientManagerImpl) startUp() {
 }
 func (cm *clientManagerImpl) clearIdleRpcClients() {

Review Comment:
   clientManagerImpl太java了,命名上能否更符合golang规范呢



##########
golang/client.go:
##########
@@ -39,6 +36,8 @@ import (
        "github.com/google/uuid"
        "github.com/lithammer/shortuuid/v4"
        "google.golang.org/grpc/metadata"
+
+       "github.com/apache/rocketmq-clients/golang/utils"

Review Comment:
   能否放在pkg目录下,使得pkg含义更具像化



##########
golang/client.go:
##########
@@ -48,6 +47,104 @@ type Client interface {
        GracefulStop() error
 }
 
+type isClient interface {

Review Comment:
   不可导出interface能不用最好不用,考虑代码可读性和可扩展



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to