shibd commented on PR #1029:
URL: 
https://github.com/apache/pulsar-client-go/pull/1029#issuecomment-1589370856

   @zengguan Thanks for your contribute.
   
   I have a question, As #687. Can we let the `sendRequest` event alone in one 
channel?
   
   In this way, Let `reconnectToBroker` and other operate are kept in the same 
coroutine.
   
   ```go
        for {
                select {
                case sendRequest <-p.sendRequestChan:
                    p.internalSend(sendRequest)
                case i := <-p.eventsChan:
                        switch v := i.(type) {
                        case *flushRequest:
                                p.internalFlush(v)
                        case *closeProducer:
                                p.internalClose(v)
                                return
                        }
                case <-p.connectClosedCh:
                        p.reconnectToBroker()
                case <-p.batchFlushTicker.C:
                        if p.batchBuilder.IsMultiBatches() {
                                p.internalFlushCurrentBatches()
                        } else {
                                p.internalFlushCurrentBatch()
                        }
                }
        }
   ```
   
   I think we can discuss clearly here, using channels should avoid using locks.


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