-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][client]Add setCompressMinMsgBodySize method to ProducerBuilder for compression configuration flexibility #24164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…on configuration flexibility
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBuilderImpl.java
Show resolved
Hide resolved
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerBuilder.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBuilderImpl.java
Show resolved
Hide resolved
StevenLuMT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #24164 +/- ##
============================================
+ Coverage 73.57% 74.23% +0.65%
+ Complexity 32624 32055 -569
============================================
Files 1877 1864 -13
Lines 139502 144478 +4976
Branches 15299 16484 +1185
============================================
+ Hits 102638 107251 +4613
+ Misses 28908 28758 -150
- Partials 7956 8469 +513
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…for compression configuration flexibility (apache#24164) PIP: apache#23526 #### Motivation Currently, the `ProducerBuilder` API lacks the ability to directly configure the `compressMinMsgBodySize` property during producer initialization. Users are forced to modify the internal `ProducerConfigurationData` post-creation, which: 1. **Violates encapsulation** by exposing internal configuration fields. 2. **Introduces inconsistency** with other compression settings (e.g., `compressionType`) that are already configurable via the builder. 3. **Creates usability hurdles**, requiring workarounds like: ```java Producer<byte[]> producer = client.newProducer().topic("test").create(); producer.conf.setCompressMinMsgBodySize(1024); // Insecure and error-prone ``` This change aligns the builder API with standard compression configuration patterns and improves developer ergonomics. #### Modifications 1. **API Enhancement**: - Added `compressMinMsgBodySize(int)` method to the `ProducerBuilder` interface. - Propagate the configured value to `ProducerConfigurationData` during producer initialization. 2. **Behavior Preservation**: - Default value remains unchanged if the method is not invoked. - Fully backward-compatible with existing code. 3. **Testing & Documentation**: - Added unit tests to validate compression threshold behavior via the new builder method. - Updated Javadoc and configuration examples to reflect the new API.
…for compression configuration flexibility (apache#24164) PIP: apache#23526 #### Motivation Currently, the `ProducerBuilder` API lacks the ability to directly configure the `compressMinMsgBodySize` property during producer initialization. Users are forced to modify the internal `ProducerConfigurationData` post-creation, which: 1. **Violates encapsulation** by exposing internal configuration fields. 2. **Introduces inconsistency** with other compression settings (e.g., `compressionType`) that are already configurable via the builder. 3. **Creates usability hurdles**, requiring workarounds like: ```java Producer<byte[]> producer = client.newProducer().topic("test").create(); producer.conf.setCompressMinMsgBodySize(1024); // Insecure and error-prone ``` This change aligns the builder API with standard compression configuration patterns and improves developer ergonomics. #### Modifications 1. **API Enhancement**: - Added `compressMinMsgBodySize(int)` method to the `ProducerBuilder` interface. - Propagate the configured value to `ProducerConfigurationData` during producer initialization. 2. **Behavior Preservation**: - Default value remains unchanged if the method is not invoked. - Fully backward-compatible with existing code. 3. **Testing & Documentation**: - Added unit tests to validate compression threshold behavior via the new builder method. - Updated Javadoc and configuration examples to reflect the new API.
PIP: #23526
Motivation
Currently, the
ProducerBuilderAPI lacks the ability to directly configure thecompressMinMsgBodySizeproperty during producer initialization. Users are forced to modify the internalProducerConfigurationDatapost-creation, which:compressionType) that are already configurable via the builder.This change aligns the builder API with standard compression configuration patterns and improves developer ergonomics.
Modifications
compressMinMsgBodySize(int)method to theProducerBuilderinterface.ProducerConfigurationDataduring producer initialization.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: