Skip to content

Conversation

@james-parky
Copy link
Contributor

@james-parky james-parky commented Aug 23, 2025

Improvements to the util module

There is currently only one function in the util module: retry_loop(). This PR improves this function (and therefore module) in that it:

@james-parky james-parky requested a review from a team as a code owner August 23, 2025 19:57
@james-parky james-parky force-pushed the dev-util-improvements branch from 6088278 to 1d1c2aa Compare August 23, 2025 19:59
This constant is intrinsically connected to the retry_loop() function and
therefore doesn't make sense to be free -- it is not used anywhere else.

Signed-off-by: james-parky <[email protected]>
A slight refactor to the retry_loop() function to make it more idiomatic
and shorter.

- Rather than have a u64 representing the retry interval, just make it a
  Duration, which is what it is. This also allows you to drop the
  INTERVAL_MSEC suffix as the fact it is built with Duration::from_millis
  makes that clear.
- Rather than using a infinite loop {}, just use a regular for loop of
  max_tries - 1. If all attempts at calling func() have resulted in an Err
  when we exit this for loop, we just return calling func() for the last
  time.
- There is no need to @-bind err in the Err match arm since it is not used
  anyway, so simplify with just a match on Err(_).
- Similarly, remove the @-binding for the Ok arm since it is neadlessly
  verbose.

Signed-off-by: james-parky <[email protected]>
@james-parky james-parky force-pushed the dev-util-improvements branch from 1d1c2aa to 7cf4af0 Compare August 23, 2025 20:01
Copy link
Member

@dongsupark dongsupark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

@dongsupark dongsupark merged commit 67f74bd into flatcar:main Aug 25, 2025
2 checks passed
@dongsupark
Copy link
Member

dongsupark commented Aug 25, 2025

For some reason code scanning is not running, and that prevents merge, anyway I will by pass and merge.

(After merge code scanning anyway ran and passed. https://github.com/flatcar/ue-rs/actions/runs/17204479070)

dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 27, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 27, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 30, 2025
sambonbonne pushed a commit to sambonbonne/flatcar-scripts that referenced this pull request Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants