-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic part of new wildcard mechanism. #685
Conversation
Codecov Report
@@ Coverage Diff @@
## master #685 +/- ##
=======================================
Coverage 82.70% 82.70%
=======================================
Files 46 46
Lines 7082 7082
=======================================
Hits 5857 5857
Misses 1225 1225 |
@kleunen , I have a question. I guess that subscription_map is trie map that contains subscription information and I can search it by topic_filter that could contain wildcard. I'm not sure about retaind_topic_map. Perhaps subscription_map is for online subscription and retaind_topic_map is offline subscription map ? Offline subscription means when client subscribe some topic filter and disconnect but the session remains case. It happens if client connect with CleanSession:false on MQTT v3.1.1, and SessionExpiryInterval is not zero on MQTT v5. |
Or both online and offline session are managed by subscription_map ? And retaind_topic_map is for retained message ? I mean,
retained_topic_map is used for do this efficiently ? |
yes, exactly. retained_topic_map stored the retained messages. The searching or filterering, also works the other way around: subscription_map: Stores the filters ( or subscriptions) with wildcards, and when a topic is published, the respective values are looked up in the map. retained_topic_map: Stores the retained topics (without wildcards), and when a new subscription is created (with wildcards), the retained_topic_map is searched for matching topics. |
Thanks you the answer. I understand. Lines 1497 to 1546 in 67b1953
We can treat them like as follows: Lines 1186 to 1217 in 67b1953
So far, in the do_publish(), first deliver to online and then deliver to offline. But when we update to trie version, offline and online can be mixed. ( It is up to the design policy) We can introduce the following variant type. using sub_con_variant = MQTT_NS::variant<sub_con_offline, sub_con_online>; |
It has been a while since I looked at the test_broker. You said in another comment the design is not very clear. I remember when I looked at the broker last year, the design did not make completely sense to me. It was strange for me the subscriptions were passed between online and offline clients, this is not necessary. A client will get a certain "session" when it connects to the broker, subscriptions are stored there. If the connection is lost, the session may remain active. Subscriptions are still handled. A client may reconnect to this session or request a new clean session upon reconnect. That way it is not necessary to shift subscriptions between offline and online connections. But ok, it is small piece of code, and design can be improved maybe. I would be interested to see a benchmark of the broker, i also made a small test broker last year. And it had very good performance. |
Yes we have some design choice. There are 4 subscription. All of them subscribe topic1. If online and offline elements are mixed, then the order of delivery could be as follows:
1 and 3 might have a longer time than 2 and 4 due to storage access (even if it is asynchronous access). Of course, we can achieve it using only con container. Adding offline/online member to sub_con and use it as multi_index_key. I'm not sure the works well on subscription_map. |
No description provided.