Skip to content

Add Retry function

Alejo Carballude requested to merge feature/retry_function into master

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:

  1. The function does not return an error.
  2. 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.

Other information

Additional documentation

Merge request reports