Skip to content

fix: apply pattern_auto_discovery_period in Client.subscribe - #319

Open
dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix/171
Open

dragonknightk wants to merge 1 commit into
apache:mainfrom
dragonknightk:fix/171

Conversation

@dragonknightk

Copy link
Copy Markdown

Fixes #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.

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.

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>
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.

pattern_auto_discovery_period in pulsar.Client is not used.

1 participant