RobertIndie commented on code in PR #1301:
URL: https://github.com/apache/pulsar-client-go/pull/1301#discussion_r1828680115


##########
pulsar/consumer_multitopic.go:
##########
@@ -167,6 +167,47 @@ func (c *multiTopicConsumer) AckID(msgID MessageID) error {
        return mid.consumer.AckID(msgID)
 }
 
+func (c *multiTopicConsumer) AckIDList(msgIDs []MessageID) error {
+       return ackIDListFromMultiTopics(c.log, msgIDs, func(msgID MessageID) 
(acker, error) {
+               if !checkMessageIDType(msgID) {
+                       return nil, errors.New("invalid message id type %T")
+               }
+               if mid := toTrackingMessageID(msgID); mid != nil && 
mid.consumer != nil {
+                       return mid.consumer, nil
+               }
+               return nil, errors.New("consumer is nil")
+       })
+}
+
+func ackIDListFromMultiTopics(log log.Logger, msgIDs []MessageID, findConsumer 
func(MessageID) (acker, error)) error {
+       consumerToMsgIDs := make(map[acker][]MessageID)
+       for _, msgID := range msgIDs {
+               if consumer, err := findConsumer(msgID); err == nil {
+                       consumerToMsgIDs[consumer] = 
append(consumerToMsgIDs[consumer], msgID)
+               } else {
+                       log.Warnf("Can not find consumer for %v", msgID)
+               }
+       }
+
+       ackError := make(map[string]*TopicAckError)
+       for consumer, ids := range consumerToMsgIDs {
+               if err := consumer.AckIDList(ids); err != nil {
+                       ackError[consumer.Topic()] = &TopicAckError{
+                               Err:    err,
+                               MsgIDs: ids,
+                       }
+               }
+       }
+       if len(ackError) == 0 {
+               return nil
+       } else if len(ackError) == 1 {
+               for _, topicAckError := range ackError {

Review Comment:
   +1. 



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