halfgaar / FlashMQ

FlashMQ is a fast light-weight MQTT broker/server, designed to take good advantage of multi-CPU environments
https://www.flashmq.org/
Open Software License 3.0
173 stars 24 forks source link

WIP / config suggestions #94

Closed quinox closed 1 month ago

quinox commented 3 months ago

Kind of ready if you don't mind me hacking around in FMQ_COMPARE


This branch modifies FlashMQ so that it will suggest possible fixes when an unknown configuration keyword is found. For example, when the user makes a typo and writes session instead of sessions:

Config key 'expire_session_after_seconds' is not valid (here). Did you mean: expire_sessions_after_seconds ?

The way it works: when an unknown key is found a list of all valid keys within that context are compared to the unknown key, and the one with the shortest reasonable Levenshtein distance is suggested. This distance expresses how many insertions/substitutions/deletions are needed to go from 1 word to another. In the example above the distance is 1: if you insert an s in the right place the words match.


Open questions:

quinox commented 1 month ago

In a post XZ world it's rather rude to dump so much code into a PR. I removed the inclusion of edlib from my branch and implemented the Wagner–Fischer algorithm algorithm from scratch. When you read the code you won't easily understand why the code gives the right answer, but it is clear to see it's not doing anything scary or dangerous. The algorithm itself is well documented online, a visual demo can be found here (via this page)

halfgaar commented 1 month ago

In a post XZ world it's rather rude to dump so much code into a PR. I removed the inclusion of edlib from my branch and implemented the Wagner–Fischer algorithm algorithm from scratch. When you read the code you won't easily understand why the code gives the right answer, but it is clear to see it's not doing anything scary or dangerous. The algorithm itself is well documented online, a visual demo can be found here (via this page)

Great, that does address my hesitance. I like the feature, just not the big code dump.

I left some comments.

halfgaar commented 1 month ago

I made a branch with my review and enhancement:

https://github.com/halfgaar/FlashMQ/tree/quinox-feat-config-suggestions

If you're OK with it like this, I can squash and merge.

quinox commented 1 month ago

I definitely have stuff to learn with C++.

It's all good, squash and merge away.

halfgaar commented 1 month ago

Alright, it's in master :+1: