thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
211 stars 55 forks source link

feat: Add reconnection backoff to built-in bridge #2915

Closed jarhodes314 closed 3 weeks ago

jarhodes314 commented 4 weeks ago

Proposed changes

This adds some backoff logic to the MQTT bridge reconnection based on the backoff crate. It also fixes a minor issue with the tedge_config macro I encountered in the process of making the changes.

Still TODO before merging:

Types of changes

Paste Link to the issue

Checklist

Further comments

github-actions[bot] commented 4 weeks ago

Robot Results

:white_check_mark: Passed :x: Failed :next_track_button: Skipped Total Pass % :stopwatch: Duration
452 0 3 452 100 1h15m42.817476s
codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 97.29730% with 7 lines in your changes missing coverage. Please review.

Project coverage is 78.2%. Comparing base (f186b3f) to head (e236d50). Report is 3 commits behind head on main.

Additional details and impacted files | [Files](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge) | Coverage Δ | | |---|---|---| | [...edge\_config/src/tedge\_config\_cli/models/seconds.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config%2Fsrc%2Ftedge_config_cli%2Fmodels%2Fseconds.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWcvc3JjL3RlZGdlX2NvbmZpZ19jbGkvbW9kZWxzL3NlY29uZHMucnM=) | `98.7% <100.0%> (+23.1%)` | :arrow_up: | | [...common/tedge\_config\_macros/impl/src/input/parse.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config_macros%2Fimpl%2Fsrc%2Finput%2Fparse.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWdfbWFjcm9zL2ltcGwvc3JjL2lucHV0L3BhcnNlLnJz) | `59.7% <ø> (ø)` | | | [crates/common/tedge\_config\_macros/impl/src/lib.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config_macros%2Fimpl%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWdfbWFjcm9zL2ltcGwvc3JjL2xpYi5ycw==) | `96.0% <100.0%> (+0.5%)` | :arrow_up: | | [...rates/common/tedge\_config\_macros/impl/src/query.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config_macros%2Fimpl%2Fsrc%2Fquery.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWdfbWFjcm9zL2ltcGwvc3JjL3F1ZXJ5LnJz) | `99.4% <100.0%> (-0.1%)` | :arrow_down: | | [...ates/common/tedge\_config\_macros/impl/src/reader.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config_macros%2Fimpl%2Fsrc%2Freader.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWdfbWFjcm9zL2ltcGwvc3JjL3JlYWRlci5ycw==) | `81.9% <100.0%> (+0.3%)` | :arrow_up: | | [crates/core/tedge/src/cli/config/commands/list.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcore%2Ftedge%2Fsrc%2Fcli%2Fconfig%2Fcommands%2Flist.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvcmUvdGVkZ2Uvc3JjL2NsaS9jb25maWcvY29tbWFuZHMvbGlzdC5ycw==) | `92.2% <100.0%> (-0.1%)` | :arrow_down: | | [crates/extensions/tedge\_mqtt\_bridge/src/topics.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fextensions%2Ftedge_mqtt_bridge%2Fsrc%2Ftopics.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2V4dGVuc2lvbnMvdGVkZ2VfbXF0dF9icmlkZ2Uvc3JjL3RvcGljcy5ycw==) | `71.4% <ø> (ø)` | | | [crates/extensions/tedge\_mqtt\_bridge/src/backoff.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fextensions%2Ftedge_mqtt_bridge%2Fsrc%2Fbackoff.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2V4dGVuc2lvbnMvdGVkZ2VfbXF0dF9icmlkZ2Uvc3JjL2JhY2tvZmYucnM=) | `99.1% <99.1%> (ø)` | | | [crates/extensions/tedge\_mqtt\_bridge/src/lib.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fextensions%2Ftedge_mqtt_bridge%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2V4dGVuc2lvbnMvdGVkZ2VfbXF0dF9icmlkZ2Uvc3JjL2xpYi5ycw==) | `89.3% <95.0%> (+0.2%)` | :arrow_up: | | [.../tedge\_config/src/tedge\_config\_cli/tedge\_config.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915?src=pr&el=tree&filepath=crates%2Fcommon%2Ftedge_config%2Fsrc%2Ftedge_config_cli%2Ftedge_config.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvbW1vbi90ZWRnZV9jb25maWcvc3JjL3RlZGdlX2NvbmZpZ19jbGkvdGVkZ2VfY29uZmlnLnJz) | `76.8% <73.6%> (+0.2%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2915/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge)
reubenmiller commented 3 weeks ago

@jarhodes314 Is there any insight provided to the user what the current backoff period is (e.g. a log entry)? This would be helpful to debug things when checking when the next connection attempt will be made.

jarhodes314 commented 3 weeks ago

@jarhodes314 Is there any insight provided to the user what the current backoff period is (e.g. a log entry)? This would be helpful to debug things when checking when the next connection attempt will be made.

There isn't but I'll add it