nodece commented on code in PR #805:
URL: https://github.com/apache/pulsar-client-go/pull/805#discussion_r969321432


##########
pulsar/consumer_impl.go:
##########
@@ -579,12 +589,13 @@ func (c *consumer) Seek(msgID MessageID) error {
                return newError(SeekFailed, "for partition topic, seek command 
should perform on the individual partitions")
        }
 
-       mid, ok := c.messageID(msgID)
-       if !ok {
-               return nil
+       if msgID.PartitionIdx() < 0 || int(msgID.PartitionIdx()) >= 
len(c.consumers) {

Review Comment:
   Same comment as above.



##########
pulsar/consumer_impl.go:
##########
@@ -533,17 +545,15 @@ func (c *consumer) Nack(msg Message) {
 }
 
 func (c *consumer) NackID(msgID MessageID) {
-       mid, ok := c.messageID(msgID)
-       if !ok {
-               return
-       }
-
-       if mid.consumer != nil {
-               mid.Nack()
+       partition := int(msgID.PartitionIdx())

Review Comment:
   Same comment as above.



##########
pulsar/consumer_impl.go:
##########
@@ -453,16 +465,16 @@ func (c *consumer) Ack(msg Message) error {
 
 // AckID the consumption of a single message, identified by its MessageID
 func (c *consumer) AckID(msgID MessageID) error {
-       mid, ok := c.messageID(msgID)
-       if !ok {
-               return errors.New("failed to convert trackingMessageID")
-       }
-
-       if mid.consumer != nil {
-               return mid.Ack()
+       partition := int(msgID.PartitionIdx())

Review Comment:
   Why not make a method to check the `partition` or the `msgID`?
   
   You can improve `messageID()` method.



##########
pulsar/consumer_partition.go:
##########
@@ -1444,3 +1564,210 @@ func convertToMessageID(id *pb.MessageIdData) 
trackingMessageID {
 
        return msgID
 }
+
+type chunkedMsgCtx struct {
+       totalChunks      int32
+       chunkedMsgBuffer internal.Buffer
+       lastChunkedMsgID int32
+       chunkedMsgIDs    []messageID
+       receivedTime     int64
+
+       mu sync.Mutex
+}
+
+func newChunkedMsgCtx(numChunksFromMsg int32, totalChunkMsgSize int) 
*chunkedMsgCtx {
+       return &chunkedMsgCtx{
+               totalChunks:      numChunksFromMsg,
+               chunkedMsgBuffer: internal.NewBuffer(totalChunkMsgSize),
+               lastChunkedMsgID: -1,
+               chunkedMsgIDs:    make([]messageID, numChunksFromMsg),
+               receivedTime:     time.Now().Unix(),
+       }
+}
+
+func (c *chunkedMsgCtx) refresh(chunkID int32, msgID messageID, partPayload 
internal.Buffer) {
+       c.mu.Lock()
+       defer c.mu.Unlock()
+       c.chunkedMsgIDs[chunkID] = msgID
+       c.chunkedMsgBuffer.Write(partPayload.ReadableSlice())
+       c.lastChunkedMsgID = chunkID
+}
+
+func (c *chunkedMsgCtx) firstChunkID() messageID {
+       c.mu.Lock()
+       defer c.mu.Unlock()
+       return c.chunkedMsgIDs[0]

Review Comment:
   ```suggestion
        if len(c.chunkedMsgIDs) == 0 { return messageID{} } else { return 
c.chunkedMsgIDs[0] }
   ```



-- 
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