WJL3333 commented on a change in pull request #252: URL: https://github.com/apache/pulsar-client-go/pull/252#discussion_r427035337
########## File path: pulsar/producer_partition.go ########## @@ -493,11 +637,100 @@ func (p *partitionProducer) Close() { wg.Wait() } +func (p *partitionProducer) beforeReceiveResponse(receipt *pb.CommandSendReceipt) { + if p.options.beforeReceiveResponseCallback != nil { + p.options.beforeReceiveResponseCallback(receipt) + } +} + type sendRequest struct { ctx context.Context msg *ProducerMessage - callback func(MessageID, *ProducerMessage, error) + callback *onceCallback flushImmediately bool + + sync.Mutex + callbackCalled bool + + createAt time.Time + gotSemaphoreAt time.Time + addToBuilderAt time.Time + flushAt time.Time + lastTimeCheckCtxDoneAt time.Time + receiveResponseAt time.Time + callBackCallAt time.Time +} + +type onceCallback struct { + once sync.Once + callback func(MessageID, *ProducerMessage, error) +} + +func (request *sendRequest) CallBack(messageID MessageID, msg *ProducerMessage, err error) { + request.callback.once.Do(func() { + request.callback.callback(messageID, msg, err) + request.callBackCallAt = time.Now() + log.Debugf("gotSemaphoreCost=%v, addToBuilderCost=%v, "+ Review comment: ok, i'll fix it ---------------------------------------------------------------- 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: us...@infra.apache.org