Repository navigation
fix: apply pattern_auto_discovery_period in Client.subscribe - #319
Open
dragonknightk wants to merge 1 commit into
Open
dragonknightk wants to merge 1 commit into
dragonknightk wants to merge 1 commit into
Conversation
Closes issue 171 ### Motivation `Client.subscribe` accepts `pattern_auto_discovery_period` and checks its type, but never passes it to the C++ `ConsumerConfiguration`. A regex consumer therefore always used the C++ default of 60 seconds, whatever value the caller set. ### Modifications Python wrapper (`pulsar/`): `Client.subscribe` now calls `conf.pattern_auto_discovery_period(...)`. The pybind11 binding in `src/config.cc` already exposes this setter, so no C++ change is needed. The value goes straight to the C++ setter, so the C++ rule applies unchanged: a value of 0 or less turns auto discovery off. Tests (`tests/`): `test_topics_pattern_consumer` created all three topics before subscribing, so they were found at subscribe time and the period never mattered. It now creates the third topic after subscribing, so the consumer only gets it through auto discovery. The consumer uses `InitialPosition.Earliest` so messages sent before the new topic is discovered are not lost. ### Verifying this change `test_topics_pattern_consumer` fails on the old code, where the third topic is not found within the receive timeout, and passes with the fix. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
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.
Fixes #171
Motivation
Client.subscribeacceptspattern_auto_discovery_periodand checks its type, but never passes it to the C++ConsumerConfiguration. A regex consumer therefore always used the C++ default of 60 seconds, whatever value the caller set.Modifications
Python wrapper (
pulsar/):Client.subscribenow callsconf.pattern_auto_discovery_period(...). The pybind11 binding insrc/config.ccalready exposes this setter, so no C++ change is needed. The value goes straight to the C++ setter, so the C++ rule applies unchanged: a value of 0 or less turns auto discovery off.Tests (
tests/):test_topics_pattern_consumercreated all three topics before subscribing, so they were found at subscribe time and the period never mattered. It now creates the third topic after subscribing, so the consumer only gets it through auto discovery. The consumer usesInitialPosition.Earliestso messages sent before the new topic is discovered are not lost.Verifying this change
test_topics_pattern_consumerfails on the old code, where the third topic is not found within the receive timeout, and passes with the fix.AI Disclosure
Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission.