[feat] Add consumer PriorityLevel support#1487
Open
grishaf wants to merge 2 commits intoapache:masterfrom
Open
[feat] Add consumer PriorityLevel support#1487grishaf wants to merge 2 commits intoapache:masterfrom
grishaf wants to merge 2 commits intoapache:masterfrom
Conversation
Add PriorityLevel field to ConsumerOptions to allow setting the
priority level for consumers on Shared and Failover subscriptions,
matching the Java client's ConsumerBuilder.priorityLevel(int) API.
In Shared subscription mode, the broker dispatches messages to the
highest priority consumers first (0 = max priority). In Failover
subscription mode for partitioned topics, the broker selects the
active consumer based on priority level and lexicographic consumer
name sorting.
Previously the Go client hardcoded PriorityLevel to nil in the
CommandSubscribe protobuf message. This change threads the user-
provided priority level through ConsumerOptions -> partitionConsumerOpts
-> CommandSubscribe.
Negative priority levels are rejected with InvalidConfiguration error,
matching the Java client's IllegalArgumentException behavior.
Master Issue: apache/pulsar#134
Supersedes: apache#783 (closed without merge, lacked tests and had validation bugs)
Member
|
@grishaf Please check the CI errors. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds consumer-side support for Pulsar consumer priority_level by exposing PriorityLevel on ConsumerOptions, validating configuration, and wiring the value into the subscribe command; includes new integration tests for shared + failover priority behavior.
Changes:
- Add
PriorityLeveltoConsumerOptionswith GoDoc describing shared/failover semantics. - Validate negative priority levels as
InvalidConfiguration. - Plumb
PriorityLevelthrough partition consumer options intoCommandSubscribe.PriorityLevel, and add tests covering invalid config + shared/failover scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
pulsar/consumer.go |
Adds the public ConsumerOptions.PriorityLevel field and documentation. |
pulsar/consumer_impl.go |
Adds validation for priority level and passes it into partition consumer options. |
pulsar/consumer_partition.go |
Sends the priority level in the subscribe protocol command. |
pulsar/consumer_test.go |
Adds tests for invalid priority, shared-subscription dispatch behavior, and failover-partition distribution behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Validate PriorityLevel <= math.MaxInt32 to prevent int64-to-int32 overflow when casting for the CommandSubscribe protobuf field - Assert Receive() results in TestPriorityConsumer drain loops instead of silently ignoring errors - Remove duplicate explicit Close() calls in TestPriorityConsumer and TestFailOverConsumerPriority (already handled by defer) - Rename unused parameter `at` to `_` in retryAssert callback to fix revive unused-parameter lint error
Author
|
@crossoverJie |
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.
Add PriorityLevel field to ConsumerOptions to allow setting the
priority level for consumers on Shared and Failover subscriptions,
matching the Java client's ConsumerBuilder.priorityLevel(int) API.
Negative priority levels are rejected with InvalidConfiguration error,
matching the Java client's IllegalArgumentException behavior.
Master Issue: apache/pulsar#134
Supersedes: #783 (closed without merge, lacked tests and had validation bugs)