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 2022/07/13 16:20:49 UTC

[GitHub] [pulsar-client-go] pgier commented on a diff in pull request #806: [issue 447] double check message size when client enable compress

pgier commented on code in PR #806:
URL: https://github.com/apache/pulsar-client-go/pull/806#discussion_r920270770


##########
pulsar/producer_partition.go:
##########
@@ -520,7 +520,12 @@ func (p *partitionProducer) internalSend(request *sendRequest) {
 	}
 
 	// if msg is too large
-	if len(payload) > int(p._getConn().GetMaxMessageSize()) {
+	minMessageSize := len(payload)
+	if minMessageSize > int(p._getConn().GetMaxMessageSize()) {
+		minMessageSize = len(p.batchBuilder.Compress(payload))
+	}
+
+	if minMessageSize > int(p._getConn().GetMaxMessageSize()) {

Review Comment:
   I think a short-circuit `and` will work here
   ```suggestion
   	if len(payload) > int(p._getConn().GetMaxMessageSize()) && 
   		len(p.batchBuilder.Compress(payload)) > int(p._getConn().GetMaxMessageSize()) {
   ```



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