pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #3904: [go schema] support go schema for pulsar-client-go
Date Sat, 13 Apr 2019 20:42:50 GMT
sijie commented on a change in pull request #3904: [go schema] support go schema for pulsar-client-go
URL: https://github.com/apache/pulsar/pull/3904#discussion_r275130982
 
 

 ##########
 File path: pulsar-client-go/pulsar/c_producer.go
 ##########
 @@ -212,10 +237,22 @@ func pulsarProducerSendCallbackProxy(res C.pulsar_result, message *C.pulsar_mess
 }
 
 func (p *producer) SendAsync(ctx context.Context, msg ProducerMessage, callback func(ProducerMessage,
error)) {
+	if p.schema != nil {
+		if msg.Value == nil {
+			callback(msg, errors.New("message value is nil, please check"))
+			return
+		}
+		payLoad, err := p.schema.Serialize(msg.Value)
+		if err != nil {
+			callback(msg, errors.New("serialize message value error, please check"))
+			return
+		}
+		msg.Payload = payLoad
+	}
 
 Review comment:
   I would add a else branch here:
   
   ```
   else {
       if msg.Value != nil {
           callback(msg, errors.New("message value is set but no schema is provided, please
check"))
           return
       }
   }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message