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


##########
pulsar/producer_partition.go:
##########
@@ -1050,3 +1270,41 @@ func (p *partitionProducer) _getConn() 
internal.Connection {
        //            invariant is broken
        return p.conn.Load().(internal.Connection)
 }
+
+func (p *partitionProducer) canAddToQueue(sr *sendRequest) bool {
+       if p.options.DisableBlockIfQueueFull {
+               if !p.publishSemaphore.TryAcquire() {
+                       if sr.callback != nil {
+                               sr.callback(nil, sr.msg, errSendQueueIsFull)
+                       }
+                       return false
+               }
+       } else if !p.publishSemaphore.Acquire(sr.ctx) {
+               sr.callback(nil, sr.msg, errContextExpired)
+               sr.blockCh <- struct{}{}
+               return false
+       } else if sr.totalChunks == 0 || sr.totalChunks == 1 || (sr.totalChunks 
> 1 && sr.chunkID == sr.totalChunks-1) {

Review Comment:
   OK, I has removed it. The blockCh will be closed by a method safety.
   
   totalChunks is initialized as 0. Do you think it's better to be initailized 
as 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