-
Notifications
You must be signed in to change notification settings - Fork 78
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
Simplify message filtering #147
Conversation
Hi Felix, |
Hi Jonathan, Thanks for taking a look!
As far as I understand it, paho-mqtt builds a tree to filter messages when you pass a topic to I don't see a way to reuse the paho-mqtt filtering logic, at least not directly, to filter inside only one iterator. Maybe you have some idea?
True, that's an error.
Good tip, thanks! I'll try to get that going. Maybe we can write a |
@frederikaalund, do you have any feedback? 😊 |
I added it. Do you have any feedback? |
Looks great, Jonathan! 😎 🚀 Maybe we can add pre-commit as a development dependency to the |
I would keep the installation of pre-commit separate. I have never seen it in the extra dependencies. |
All right, sounds good! 👍 |
Been a busy week at work, so I apologize for the delay. I'll try to set some time aside for asyncio-mqtt this weekend. Great to see this PR as per our discussion! Let me have a look. :)
As long as we don't change the semantics of
In my oppinion, yes! I propose that we do the following:
This results in the following API (example): async with Client("test.mosquitto.org") as client:
async with client.messages() as messages:
await client.subscribe("measurements/#")
async for message in messages:
if message.topic.matches("measurements/#"):
print(f"Measurement: {message.payload}")
if message.topic.matches("measurements/+/something"):
print(f"Measurement something: {message.payload}") Note that both I vote that we keep the "old" The biggest drawback of this new API is that we have to replicate existing paho-mqtt functionality in the Again thanks for this PR. I invite everyone to give their oppinion in this discussion. 👍 ~Frederik |
|
Thanks for the feedback, Frederik!
Sounds good! Using an own
Great find, thanks Jonathan! |
92f2418
to
f5e32b9
Compare
Codecov Report
@@ Coverage Diff @@
## master #147 +/- ##
========================================
+ Coverage 89.4% 90.9% +1.4%
========================================
Files 7 7
Lines 552 704 +152
Branches 110 150 +40
========================================
+ Hits 494 640 +146
- Misses 37 41 +4
- Partials 21 23 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Finally had some time again! 😊 Jonathan, following the I'm glad for all feedback, I'm still a bit unsure if what I'm doing makes sense 😄
Here I got stuck a bit. We can't simply use I could set the |
🎉 |
Great to see continued work on this. Keep it up. 😄 👍
I was thinking something like this:
Does it make sense? If not, just let me know and I'll try to write up some pseudo code for it. :) |
It's kind of a poor man's implementation of the Observer pattern. 😁 |
ec4cf23
to
25274b9
Compare
That's what I was missing! Thank you for your always very well thought out reviews, Frederik! 🎉 I think this is done from my side. Summary of changes:
I'm glad about any feedback! When you give the approval I'll merge 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a busy weekend, so my review is pretty short.
Overall, it looks good! :) I like the new API a lot (it feels right).
Decisions from here:
- Should we release a 1.0.0 before we merge this in?
Thanks for the comments, Frederik! 🚀
Staying on 0.x is cheating a bit, but I think the flexibility is great for us maintainers, especially with new ideas like discussed in the anyio PR. In my opinion we're playing fair if we release 0.15 with this and then remove the old |
Too hurt as few users as possible let's at least have a long deprecation period on the old ( |
Let me know if you need more feedback/review from me. 👍 It's been a busy week, so I kind of lost track of these PRs/issues. |
d8541e5
to
9038718
Compare
9038718
to
b057d48
Compare
b057d48
to
4d43388
Compare
hi @empicano . Sorry but the deprecation message was not very clear to me in regards to how to use I currently have a code that looks like this: Is it proper for me to simply change the last few lines to look like :
? or is there a better recommended way? Please document a before and after example, so people like me don't have to bother you. ;) Thanks, |
Hi Flavio, Sorry for the confusion! I admit the deprecation message could be a bit more descriptive.
The main difference between Hope that helps! 🙂 |
Hi Frederik and Jonathan,
We discussed simplifying the message-filtering logic a few days ago. I played around with it for a bit and wanted your opinion. Nothing that's working yet, but for feedback on the general direction.
The idea is to simplify the current way of filtering messages to something like:
For this, we need to reimplement paho-mqtt's message filtering logic in a new
MqttMessage
class that subclasses the paho-mqtt one.In our initial discussion, you noted that you had an idea of how to add this in a backward-compatible way, Frederik. Could you give me some pointers how? 😊
Things I'm unsure about:
one/#/three
~ Felix