Draft
Conversation
Subscription information was being converted back and forth between several classes, resulting in much unneeded object creation. But in the end it would always end up as Subscription. - This removes all the intermediate Objects, simplifying the code. - This includes the removal of the SharedSubscription class, since in the end, those are also turned into normal Subscriptions, making the extra class meaningless. - The logic contained many superfluous if/else checks for subscriptionIdentifiers caused by the wrapping and unwrapping of Subscription data. - All methods that would take several parameters with subscription information now simply accept a subscription.
Subscriptions are registered on the Session, so when an unsubscribe is received, the subscription can be fetched from the Session. This allows the subscription-remove functions to be greatly simplified.
The topic used internally for a Subscription can be changed by a listener to be different from the topic the client subscribed to. This process is completely transparent to the client. - A TopicRewriter can be registered on the server to handle the topic rewriting. - Subscription now has a topicInternal and a topicClient. - For the client, messages sent to topicInternal appear to have been sent to topicClient.
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.
This PR is the reason I made #931, since that PR makes this one a lot simpler :)
There is no rush for a detailed code review on this, but it may provide some context for the other one, and we may need to discuss if this is a feature that fits Moquette in the first place.
What does this PR do?
Topic rewriting, meaning the server internally changes the topic that the client subscribes to, without the client noticing. The rewriting is done by a class implementing the TopicRewriter interface that can be set when starting the Broker.
The three main use cases are:
$select. Client subscribing tov1.1/Things?$select=id,namewould receive the same messages as those subscribing tov1.1/Things?$select=name,id, but the embedding server needs to publish two messages, one for each topic. With topic rewriting, these topics can be merged into one topic, meaning the embedding server only needs to publish one message.I'm currently testing it with a branch of FROST-Server to see if it works as expected.
It currently only rewrites topic on subscriptions, not on publishes. If there is interest, I could implement that as well, though I currently don't need that.
Checklist
[ ] I have made corresponding change to the default configuration files (and/or docker env variables)Related issues