fix: clear all retained entity messages on entity deregistration#3681
Conversation
Robot Results
|
81deebf to
8cd679f
Compare
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
didier-wenzek
left a comment
There was a problem hiding this comment.
I would consider to fully remove the concept of MqttConnector API and to directly use regular mqtt_channel connections.
| // Clear all retained metadata/data associated with the entity | ||
| match self.mqtt_connector.connection_for(&entity.topic_id).await { |
There was a problem hiding this comment.
I would consider to spawn the whole loop in a background task (including open & close of the connection).
There was a problem hiding this comment.
Does that really help? Because, even if we spawn it as a different task, we'll still have to wait for that task to finish here, as we can't return from this deregister call before everything is cleared.
There was a problem hiding this comment.
as we can't return from this
deregistercall before everything is cleared.
Why not? This was my proposal. I see clearing all these retained messages as a follow-up task of entity de-registration. But, I agree that this can be discussed.
There was a problem hiding this comment.
I see clearing all these retained messages as a follow-up task of entity de-registration. But, I agree that this can be discussed.
Since one of the main highlights of the HTTP API was the feedback after something is complete, returning while the operation is still in-progress in the background feels a bit weird. As a user, I personally prefer the deterministic behaviour, esp since this is a rare operation and hence I'm okay with waiting a bit more until everything is fully complete. But I'll let @reubenmiller also pitch in, if the proposed eventual cleanup is sufficient.
didier-wenzek
left a comment
There was a problem hiding this comment.
Looks good. However, two failing unit-tests require investigation.
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved. Thank you for taking the time to find the correct approach.
5cec94f to
405330d
Compare
Proposed changes
On entity deregistration, fetch all retained messages associated with that entity and its children and then clear them all.
Types of changes
Paste Link to the issue
#3632
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments