Support consumer key-shared policy#420
Merged
BewareMyPower merged 1 commit intoapache:masterfrom Jun 11, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for the KeyShared consumer policy (including sticky mode) in the Node.js Pulsar client and verifies its behavior.
- Introduce parsing and application of
keySharedPolicy(mode, out-of-order flag, sticky ranges) inConsumerConfig - Add a
testStickyConsumerinconsumer.test.jsto validate sticky key distribution - Include C++ enums and configuration constants to wire up the new policy
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ConsumerConfig.cc | Parse keySharedPolicy object, validate ranges and set the C++ KeySharedPolicy |
| tests/consumer.test.js | New testStickyConsumer to send messages with random keys and assert sticky distribution |
Comments suppressed due to low confidence (2)
tests/consumer.test.js:522
- [nitpick] The new test focuses on sticky mode but doesn't cover the
allowOutOfOrderDeliveryflag or otherKeySharedModevariants. Consider adding tests for those configurations.
}, 20000);
src/ConsumerConfig.cc:363
- [nitpick] Consider adding explicit bounds checks for
startandend(e.g. 0 ≤ value ≤ 65535) to guard against out-of-range values and avoid passing invalid ranges to the C++ client.
for (uint32_t i = 0; i < rangesArray.Length(); i++) {
BewareMyPower
approved these changes
Jun 11, 2025
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.
Motivation
#408
Modifications
Verifying this change
Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)