feat: add optional break conditions to tedge mqtt sub#3445
feat: add optional break conditions to tedge mqtt sub#3445rina23q merged 2 commits intothin-edge:mainfrom
tedge mqtt sub#3445Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
|
@rina23q Just naming things. It might be more useful to align with naming used by mosquitto_sub (to make it easier to switch between the tools)
Plus, it the previous names (window and packets) are super obvious what they mean. |
|
|
||
| // the default keepalive in rumqttc is 60 sec | ||
| if !cmd.window.is_zero() && cmd.window.as_secs() < 60 { | ||
| options.set_keep_alive(cmd.window); |
There was a problem hiding this comment.
I'm okay with that. But be aware that the precision is 60 sec if the timeout is greater than 60s.
An option, is to set the keep alive to 5 seconds to have a more precise timeout.
There was a problem hiding this comment.
If user gives 1m10s, then indeed with 60s keepalive, the command will break after 2m.
On the other hand, if user provides 1h, every 5s ping sounds a bit too much.
Does it make simplify if we set the same keepalive value as provided unless it's bigger than the maximum value?
the maximum Keep Alive interval is 18 hours, 12 minutes, and 15 seconds. (https://www.hivemq.com/blog/mqtt-essentials-part-10-alive-client-take-over/)
There was a problem hiding this comment.
if user provides 1h, every 5s ping sounds a bit too much.
I would not bother too much with that. This command being used locally and for test purposes.
| /// Set a timeout duration (e.g., 60s, 1h). Use 0 for no timeout | ||
| #[clap(long, default_value = "0")] | ||
| window: SecondsOrHumanTime, | ||
| /// Set the number of packets before stopping. Use 0 for unlimited | ||
| #[clap(long, default_value = "0")] | ||
| packets: u32, |
There was a problem hiding this comment.
A cleaner approach is to use optional inputs instead of magic values.
| /// Set a timeout duration (e.g., 60s, 1h). Use 0 for no timeout | |
| #[clap(long, default_value = "0")] | |
| window: SecondsOrHumanTime, | |
| /// Set the number of packets before stopping. Use 0 for unlimited | |
| #[clap(long, default_value = "0")] | |
| packets: u32, | |
| /// Set a timeout duration (e.g., 60s, 1h). | |
| #[clap(long)] | |
| window: Option<SecondsOrHumanTime>, | |
| /// Set the number of packets before stopping. | |
| #[clap(long)] | |
| packets: Option<u32>, |
|
|
||
| // the default keepalive in rumqttc is 60 sec | ||
| if !cmd.window.is_zero() && cmd.window.as_secs() < 60 { | ||
| options.set_keep_alive(cmd.window); |
There was a problem hiding this comment.
I'm okay with that. But be aware that the precision is 60 sec if the timeout is greater than 60s.
An option, is to set the keep alive to 5 seconds to have a more precise timeout.
|
Added system tests in deb4b54. The good highlight is, now we can use |
Robot Results
|
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved. Really convenient!
* timeout duration (--duration, -W) * number of received packets (--count, -C) Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
deb4b54 to
ef7029a
Compare
Removed the MQTT keepalive mechanism for timeout introduced by thin-edge#3445. Instead, using a thread in charge of timeout. Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>

Proposed changes
This PR introduces two new options to
tedge mqtt subto give a break to the command.--duration:tedge mqtt subbreaks after given time. e.g.,--count:tedge mqtt subbreaks after the given number of packets received. e.g.,Types of changes
Paste Link to the issue
#3412
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments