PIP-468: V5 policy options use builder pattern#25657
Merged
Merged
Conversation
Convert the V5 client policy options from records (with public canonical constructors) into final classes whose only construction paths are an explicit Builder and a small set of named factory methods. This keeps the public surface to the deliberate, documented combinations and lets the classes evolve without breaking source compatibility on every new field. Refactored: BackoffPolicy, BatchingPolicy, ChunkingPolicy, CompressionPolicy, ConnectionPolicy, DeadLetterPolicy, EncryptionPolicy, ProcessingTimeoutPolicy, TlsPolicy, TransactionPolicy. Each now exposes: - Private constructor. - private final fields with record-style accessors (foo() — backward compatible with existing callers). - A static `builder()` plus a fluent inner `Builder` with javadoc per knob. - Small, opinionated factories where there's an obvious dominant case (e.g. CompressionPolicy.disabled(), TlsPolicy.ofInsecure(), BatchingPolicy.ofDisabled(), BackoffPolicy.fixed(), BackoffPolicy.exponential(initial, max), ProcessingTimeoutPolicy.of(timeout), EncryptionPolicy.forProducer / forConsumer). - Lombok @EqualsAndHashCode + @tostring to preserve value-type semantics. Updated callers (Examples.java, V5DeadLetterPolicyTest, V5TransactionTest, V5ProducerBatchingTest) to use the builder.
lhotari
approved these changes
May 3, 2026
Member
lhotari
left a comment
There was a problem hiding this comment.
LGTM, one unrelated question about BackoffPolicy.
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Convert the V5 client policy options from records (with public canonical constructors) into final classes whose only construction paths are an explicit
Builderand a small set of named factory methods. This keeps the public surface to deliberate, documented combinations and lets the classes evolve without breaking source compatibility every time a new field is added.Refactored:
BackoffPolicy,BatchingPolicy,ChunkingPolicy,CompressionPolicy,ConnectionPolicy,DeadLetterPolicy,EncryptionPolicy,ProcessingTimeoutPolicy,TlsPolicy,TransactionPolicy.Each now has:
foo()— backward compatible with existing callers).builder()plus a fluent innerBuilderwith javadoc on each knob.CompressionPolicy.disabled(),TlsPolicy.ofInsecure(),BatchingPolicy.ofDisabled(),BackoffPolicy.fixed/exponential(initial, max),ProcessingTimeoutPolicy.of(timeout),EncryptionPolicy.forProducer/forConsumer).@EqualsAndHashCode+@ToStringto preserve value-type semantics.Updated callers —
Examples.java,V5DeadLetterPolicyTest,V5TransactionTest,V5ProducerBatchingTest— to use the builder/factory entry points.Test plan
pulsar-client-api-v5andpulsar-brokercheckstyle clean.V5DeadLetterPolicyTest,V5TransactionTest,V5ProducerBatchingTest,V5ProcessingTimeoutTest.