Add Retry function
Related tasks
Context
In some contexts, critical operations need to be retried until a timeout is hit, or indefinitely. This is something that can be handled locally in the code, but it is happening often enough in ign-go
dependencies that a generic function to retry code has is introduced here.
Change
A new Retry
function is introduced that repeatedly calls a function until either:
- The function does not return an error.
- An optional timeout is hit.
The Retry
function will only return an error when a timeout is hit. In all other cases, it will keep calling the passed function until it returns no error.