-
Notifications
You must be signed in to change notification settings - Fork 66
feat: support retained-only flag in tedge mqtt sub #3494
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
feat: support retained-only flag in tedge mqtt sub #3494
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
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.
Why not.
In practice, this command will behave as expected, but beware that retained messages are weird.
- There is no guarantee that all the retained messages are sent first on connect
- The retain flag is cleared for retained message updates.
Robot Results
|
Yes, though it seems that it is common behaviour (though maybe not in the spec). Or at least when using
Yes, this is the part which catches most new users out. The retained flag is only added to messages and sent to the client if the messages are retained on the MQTT broker prior to the client connecting. But if mosquitto_sub already offers it, then it seems to be more-or-less accepted. |
Yes. And, as long as you're aware of the lack of guarantees, it's really convenient. |
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
20cba40
to
407c4de
Compare
Seems like this added a flaky test. I'll review the test to see how it can be made more reliable. |
79287b5
to
5cf240f
Compare
I was able to reproduce the flaky test locally, and tweak the testings to be more reliable. I suspect the root cause was the non-retained message was sometimes being published before the subscription was established. Now an additional sleep has been added before publishing the message. Before
After
|
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
5cf240f
to
75ac45f
Compare
Proposed changes
Adding support for the
--retained-only
flag (same function as the mosquitto_sub flag of the same name), to allow users to only get the retained messages from the local MQTT broker.Note: When subscribing to the retained messages, it will only return the messages with the retain flag set, and it will actively stop when receiving the first non-retained message, or if the user specifies a duration timeout.
Below shows the most common usage of the flag.
tedge mqtt sub '#' --retained-only --duration 1s
The change will also allow the remaining usage of
mosquitto_sub
in the system tests to be replaced withtedge mqtt sub
and also providing a useful tool to users.Types of changes
Paste Link to the issue
Checklist
just prepare-dev
once)just format
as mentioned in CODING_GUIDELINESjust check
as mentioned in CODING_GUIDELINESFurther comments