You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/28 14:34:53 UTC

[GitHub] [pulsar-client-go] wolfstudy commented on a change in pull request #622: Fix logic of command for sendError

wolfstudy commented on a change in pull request #622:
URL: https://github.com/apache/pulsar-client-go/pull/622#discussion_r717645039



##########
File path: pulsar/internal/connection.go
##########
@@ -752,38 +752,51 @@ func (c *connection) handleAuthChallenge(authChallenge *pb.CommandAuthChallenge)
 	c.writeCommand(baseCommand(pb.BaseCommand_AUTH_RESPONSE, cmdAuthResponse))
 }
 
-func (c *connection) handleSendError(cmdError *pb.CommandError) {
-	c.log.Warnf("Received send error from server: [%v] : [%s]", cmdError.GetError(), cmdError.GetMessage())
+func (c *connection) handleSendError(sendError *pb.CommandSendError) {
+	c.log.Warnf("Received send error from server: [%v] : [%s]", sendError.GetError(), sendError.GetMessage())
 
-	requestID := cmdError.GetRequestId()
+	producerID := sendError.GetProducerId()
 
-	switch cmdError.GetError() {
+	c.listenersLock.RLock()
+	producerListener := c.listeners[producerID]
+	c.listenersLock.RUnlock()
+
+	switch sendError.GetError() {
 	case pb.ServerError_NotAllowedError:
-		request, ok := c.deletePendingRequest(requestID)
+		_, ok := c.deletePendingProducers(producerID)
 		if !ok {
 			c.log.Warnf("Received unexpected error response for request %d of type %s",
-				requestID, cmdError.GetError())
+				producerID, sendError.GetError())
 			return
 		}
 
-		errMsg := fmt.Sprintf("server error: %s: %s", cmdError.GetError(), cmdError.GetMessage())
-		request.callback(nil, errors.New(errMsg))
+		c.log.Warnf("server error: %s: %s", sendError.GetError(), sendError.GetMessage())
 	case pb.ServerError_TopicTerminatedError:
-		request, ok := c.deletePendingRequest(requestID)
+		_, ok := c.deletePendingProducers(producerID)

Review comment:
       In CommandSendError, just only `ProducerId` and `SequenceId`
   
   ```
   type CommandSendError struct {
   	ProducerId           *uint64      `protobuf:"varint,1,req,name=producer_id,json=producerId" json:"producer_id,omitempty"`
   	SequenceId           *uint64      `protobuf:"varint,2,req,name=sequence_id,json=sequenceId" json:"sequence_id,omitempty"`
   	Error                *ServerError `protobuf:"varint,3,req,name=error,enum=pulsar.proto.ServerError" json:"error,omitempty"`
   	Message              *string      `protobuf:"bytes,4,req,name=message" json:"message,omitempty"`
   	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
   	XXX_unrecognized     []byte       `json:"-"`
   	XXX_sizecache        int32        `json:"-"`
   }
   ```




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org