GPrabhudas commented on a change in pull request #560:
URL: https://github.com/apache/pulsar-client-go/pull/560#discussion_r673203837
##########
File path: pulsar/internal/commands.go
##########
@@ -269,6 +270,117 @@ func serializeBatch(wb Buffer,
wb.PutUint32(checksum, checksumIdx)
}
+// copy of the method serializeBatch(....) with an extension to encrypt payload
+func serializeBatchWithEncryption(wb Buffer,
+ cmdSend *pb.BaseCommand,
+ msgMetadata *pb.MessageMetadata,
+ uncompressedPayload Buffer,
+ compressionProvider compression.Provider,
+ KeyReader crypto.KeyReader,
+ encryptionKeys []string,
+ msgCrypto crypto.MessageCrypto,
+ cryptoFailureAction int,
+) {
+ // Wire format
+ // [TOTAL_SIZE] [CMD_SIZE][CMD] [MAGIC_NUMBER][CHECKSUM]
[METADATA_SIZE][METADATA] [PAYLOAD]
+
+ // compress the payload
+ compressedPayload := compressionProvider.Compress(nil,
uncompressedPayload.ReadableSlice())
+
+ encryptedPayload := encryptPayload(msgMetadata,
+ msgCrypto,
+ KeyReader,
+ encryptionKeys,
+ compressedPayload,
+ cryptoFailureAction)
+
+ // there was a error in encrypting the payload and
+ // crypto failure action is set to
crypto.ProducerCryptoFailureActionFail
+ if encryptedPayload == nil {
Review comment:
Its better to throw an exception because client is setting
`ProducerCryptoFailureActionFail` to fail.
--
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]