Skip to content

Support consumer key-shared policy #420

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

shibd
Copy link
Member

@shibd shibd commented Jun 10, 2025

Motivation

#408

Modifications

  • Support consumer key-shared policy

Verifying this change

  • Add testStickyConsumer to cover this.
  • Other case covered by the CPP client.

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)

@shibd shibd added this to the 1.14.0 milestone Jun 10, 2025
@shibd shibd self-assigned this Jun 10, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) in ConsumerConfig
  • Add a testStickyConsumer in consumer.test.js to 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 allowOutOfOrderDelivery flag or other KeySharedMode variants. Consider adding tests for those configurations.
}, 20000);

src/ConsumerConfig.cc:363

  • [nitpick] Consider adding explicit bounds checks for start and end (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 BewareMyPower merged commit 52ab66a into apache:master Jun 11, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants