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


##########
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:
   Good suggestion. Original code may cause index out of range error.



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