fix subscribers list#246
Merged
Gsantomaggio merged 10 commits intomasterfrom Sep 25, 2025
Merged
Conversation
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Closed
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the consumer/subscriber system to use numeric IDs instead of string names for internal tracking, addressing issues with subscriber list management. The changes improve performance and eliminate bugs related to string-based subscriber identification.
- Converts subscriber tracking from string-based names to integer-based IDs for better performance and reliability
- Updates MessageContext and EventContext to include stream information directly instead of requiring lookups
- Adds validation for max_subscribers_by_connection limits and introduces new exception types
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rstream/consumer.py | Major refactor of subscriber tracking from string to integer IDs, updated MessageContext structure |
| rstream/superstream_consumer.py | Updated to use integer subscriber IDs instead of string references |
| rstream/client.py | Changed frame handling to use integer subscriber IDs, renamed get_available_id to inc_available_id |
| rstream/exceptions.py | Added new exception classes for max consumers/publishers per connection limits |
| rstream/constants.py | Added MAX_ITEM_ALLOWED constant for connection limits |
| tests/util.py | Updated test utilities to use new MessageContext structure and adjusted timing |
| tests/test_consumer_validate_id.py | New comprehensive test file for subscriber ID validation and stream routing |
| tests/test_consumer.py | Updated existing tests to use integer subscriber IDs and new MessageContext structure |
| docs/examples/ | Updated all example files to use new MessageContext.stream property instead of method calls |
Comments suppressed due to low confidence (1)
rstream/consumer.py:350
- The handler removal is using
subscriber.reference(which can be None) instead ofstr(subscriber_id)to match how handlers were added in the subscribe method.
await subscriber.client.stop_queue_listener_task(subscriber_id=subscriber_id)
subscriber.client.remove_handler(
schema.Deliver,
name=subscriber.reference,
)
subscriber.client.remove_handler(
schema.MetadataUpdate,
name=subscriber.reference,
)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@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: #241
This PR refactors the consumer/subscriber system to use numeric IDs instead of string names for internal tracking, addressing issues with subscriber list management. The changes enhance performance and eliminate bugs associated with string-based subscriber identification.
Breaking changes
subscriber_id, but instead thereferenceThe bug was here [Tag 0.3.1]:
rstream/rstream/consumer.py
Lines 197 to 203 in 654a9ef
Given two references with the same name the
subscriber = self._subscribers[reference]is not consistent.With this PR the
_subscribersis[int, _Subscriber]Where the int is the subscriber id that must be unique for connection by protocol.
get_streamfunctionmessage_context.consumer.get_stream(message_context.subscriber_name)The
get_streamis not needed anymore since thestreamis now passed on themessage_contextand alsoevent_contextsubscribe_nameis now optional