-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add publish callback #263
base: master
Are you sure you want to change the base?
Add publish callback #263
Conversation
A few points from a really quick look:
I'm not going to have time to fully review this in its current state (I find it often takes as long to review code as it does to write it, so will await something that you feel is ready for submission or where you have a specific question). You appear to have a decent general approach, but it needs some more work (and tests). Unfortunately with this kind of change I've found that you will find issues as you go (you probably don't understand the entirety of the requirement yet) and tests are essential (hopefully the tests I've already written will provide a decent starting point and highlight some areas where there have been issues in the past). |
Thanks @MattBrittan.
Thank you for reiterating this point. I also noticed that the queue supports both memory and file persistence, and the enqueue/dequeue process involves serialization and deserialization. I realize that I cannot serialize the callback function, which means it will have to stay in memory. This creates a limitation for such a callback system.
|
This is why I did not implement the callbacks at the time persistance was implemented, it gets a bit trickey (and I don't think there is a perfect solution). Assigning a
). If we take this approach I'd also suggest adding a version flag as the first byte (existing packets should have a 3 in the top 4 bits) as this will enable non-breaking changes in the future. However I wonder if it might make more sense to pass this off to the
This could be in addition to the current queue (so maintaining compatibility - the callback would be called with an error if the queue does not support ID handling) or replace the current queues (I doubt many users have implemented custom queues and we are still pre v1 so breaking changes are OK). Note: This is not something I have really thought through in detail (chose a uint64 rather than a string because that would be eaisied to encode for use in a filename etc and should be big enough to ensure uniqueness). |
Can you explain more? I could not find any related code where 3 is added in the top 4 bits.
I believe this can be done as a follow-up when such functionality is needed. Not doing it now does not close the door for the future, so it is fine to decouple from the current effort. |
The first byte will be a "PUBLISH Fixed Header" (as publish messages are the only thring written to the queue).
Correct - but it is nice to try an design things so it is possible to add functionality later without breaking current programs. |
Do you prefer to add I recommend keeping it separate as it is not sent via MQTT protocol, and the same format does not apply. We can have more freedom in the format, for example, add a version number as the first byte instead of trying to write hacky code to make |
Users should be able to use As mentioned above my preference would be that the location the ID is stored be handled by the queue store (for example the filestore could use the ID as a filename rather than it being stored within the file). |
Created #264 to implement the UUID in queue store. |
Attempt 2 to get feedback on the logic.
Primarily, instead of the client creating the channel to receive the publish, I am making it at the
autopaho
level to ensure the channel can survive reconnects.TODO: