-
Notifications
You must be signed in to change notification settings - Fork 93
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
Allow initializing MIDs with in-use IDs, remove Clear(), use RWMutex for Get() #141
Conversation
An alternative would be to add a |
Good points, I'll find some time to update this PR. |
PR updated based on the feedback. As a side note, I think that using names like "message ID" and "MID" should be avoided because the MQTT spec uses "Packet ID" instead. |
@MattBrittan I just realized that this would prevent users from making their own Do we even need to support custom packet ID allocators? @alsm, did you have a use-case for custom packet ID allocators in mind when you implemented this? |
Sorry - I'm not seeing (possibly missing something!) why this is a requirement? 'paho' only needs access to
I guess this is possible in the current design (just load the data the first time one of the functions is called). The alternative would be a callback just before sending If |
Paho also needs access to some way to mark a packet ID as in-use if it is connecting with an existing session, no? That's why I'm thinking that the marking of Packet IDs as in-use needs to be a part of the MIDService interface (e.g., with a
Yep, I think around there sounds right. Before sending the CONNECT packet, Paho will get the session state from the persistence implementation and mark the relevant packet IDs as in-use. When the CONNACK comes back, Paho will do whatever delivery retry it needs to do per the MQTT requirements. |
I think a lot of this comes down to a discussion around the desired level of functionality in the If Doing things this way keeps So, with the above in mind, I feel that the task of loading the session state (to pre-populate I'll try to put some time over the next couple of weeks into fleshing out how the store might work; perhaps it might be worth having a discussion around this (hopefully you have had a chance to talk to Al?). |
Good point.
Why MIDService and not the persistence implementation (however that'd look like)? I'm wondering if you have a good mental model for what should belong in the packet ID tracker vs. the persistent session store. It might clarify my thinking.
Happy to have a discussion on or off GitHub—you have my e-mail address. Yep, I've talked to Al! |
Just a thought at this point. The lifecycle of a MID matches that of an outgoing message (allocated when message created, released after appropriate acknowledgments received) so it may make sense to combine the two. |
I'll close this one off as I believe PR #172 addresses the requirement in a different way (and significantly changes how message IDs are handled meaning this PR is probably no longer relevant). |
As discussed in #134, we need a way to claim packet IDs as a prerequisite for connecting with existing sessions. This implements that. In addition, I put an RWMutex in since calls to Get() can safely happen in parallel.