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

 ##########
 File path: pulsar/impl_message.go
 ##########
 @@ -126,3 +142,36 @@ func (msg *message) EventTime() time.Time {
 func (msg *message) Key() string {
        return msg.key
 }
+
+func newAckTracker(size int) *ackTracker {
+       var batchIDs *big.Int
+       if size <= 64 {
+               shift := uint32(64 - size)
+               setBits := ^uint64(0) >> shift
+               batchIDs = new(big.Int).SetUint64(setBits)
+       } else {
+               batchIDs, _ = new(big.Int).SetString(strings.Repeat("1", size), 
2)
+       }
+       return &ackTracker{
+               size:     size,
+               batchIDs: batchIDs,
+       }
+}
+
+type ackTracker struct {
+       sync.Mutex
+       size     int
+       batchIDs *big.Int
+}
+
+func (t *ackTracker) ack(batchID int) {
+       t.Lock()
+       defer t.Unlock()
+       t.batchIDs = t.batchIDs.SetBit(t.batchIDs, batchID, 0)
+}
+
+func (t *ackTracker) cleared() bool {
 
 Review comment:
   Maybe we can use a term that's more specific to acks rather than bitset. eg; 
    * `IsComplete()` 
    * `EverythigWasAcked()`
   
   Another option could be to return bool from `ack(batchID int)`. That will 
also avoid getting the mutex twice each time.

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