GPrabhudas commented on a change in pull request #560:
URL: https://github.com/apache/pulsar-client-go/pull/560#discussion_r696582669



##########
File path: pulsar/internal/commands.go
##########
@@ -221,9 +222,21 @@ func serializeBatch(wb Buffer,
        cmdSend *pb.BaseCommand,
        msgMetadata *pb.MessageMetadata,
        uncompressedPayload Buffer,
-       compressionProvider compression.Provider) {
+       compressionProvider compression.Provider,
+       encryptor crypto.Encryptor) {
        // Wire format
        // [TOTAL_SIZE] [CMD_SIZE][CMD] [MAGIC_NUMBER][CHECKSUM] 
[METADATA_SIZE][METADATA] [PAYLOAD]
+
+       // compress the payload
+       compressedPayload := compressionProvider.Compress(nil, 
uncompressedPayload.ReadableSlice())
+
+       // encrypt the compressed payload
+       encryptedPayload, err := encryptor.Encrypt(compressedPayload, 
crypto.NewMessageMetadataSupplier(msgMetadata))
+       if err != nil {
+               // error occurred while encrypting the payload, 
ProducerCryptoFailureAction is set to Fail
+               panic(fmt.Sprintf("Encryption of message failed, 
ProducerCryptoFailureAction is set to Fail. Error :%v", err))

Review comment:
       @cckellogg shall I'll make changes to return an error from flush methods 
:)




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