sijie commented on a change in pull request #82: Added a message id tracker for 
acking messages that are batched.
URL: https://github.com/apache/pulsar-client-go/pull/82#discussion_r342363881
 
 

 ##########
 File path: pulsar/impl_message.go
 ##########
 @@ -18,30 +18,31 @@
 package pulsar
 
 import (
+       "math/big"
+       "strings"
+       "sync"
        "time"
 
-       "github.com/apache/pulsar-client-go/pkg/pb"
        "github.com/golang/protobuf/proto"
-)
 
-func earliestMessageID() MessageID {
-       return newMessageID(-1, -1, -1, -1)
-}
+       "github.com/apache/pulsar-client-go/pkg/pb"
+)
 
 type messageID struct {
        ledgerID     int64
        entryID      int64
        batchIdx     int
        partitionIdx int
+
+       tracker *ackTracker
 
 Review comment:
   @merlimat @cckellogg I understand the implementation follows the Java 
implementation. The approach doesn't have any problem here. However I think we 
should do it in golang's way. We can follow what @wolfstudy suggested. It is 
exactly same as your approach but much clearer.
   
   ```
   type messageID struct {
        ledgerID     int64
        entryID      int64
        batchIdx     int
        partitionIdx int
   }
   type msgTracker struct {
        msgID   *messageID
        tracker *ackTracker
   }
   type ackTracker struct {
        sync.Mutex
        size     int
        batchIDs *big.Int
   }
   func newMsgTracker(msgID *messageID, tracker *ackTracker) *msgTracker {
        return &msgTracker{
                msgID:   msgID,
                tracker: tracker,
        }
   }
   func newMessageID(ledgerID int64, entryID int64, batchIdx int, partitionIdx 
int) MessageID {
        return &messageID{
                ledgerID:     ledgerID,
                entryID:      entryID,
                batchIdx:     batchIdx,
                partitionIdx: partitionIdx,
        }
   }
   ```
   
   In this way, msgTracker inherits all the fields from `messageID` and it 
avoids polluting `messageID` struct.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to