Package retry manages the execution of certain pieces of code that must run a specific number of times before being considered as failed.
The execution of a function will be considered failed only if all the tries returned an error, when it happens the 'With*' function will return all the errors in a ErrorGroup.
If the TryFunc return a nil error at any moment it will be considered a successful execution and nil will be returned by the 'With*' function.
To know more about the ErrorGroup go to https://github.com/txgruppi/errorgroup-go
How many times TryFunc will execute?
The general rule is 'len(BackoffArray) + 1'
This happens because the BackoffArray is an array of intervals and makes no sense to have an interval after the last execution. Because of this every time the last interval is extracted from the BackoffArray the TryFunc is executed one more time. If you want to run the function only one time you should give a BackoffArray with zero items.
WithBackoffArray runs the TryFunc with intervals from the given BackoffArray
It is important to notice that the TryFunc will run 'len(BackoffArray) + 1' times
WithFixedInterval runs the TryFunc with a BackoffArray created with the given 'interval' repeated 'repeat' times
It is important to notice that the TryFunc will run 'repeat + 1' times
BackoffArray an vector of interval to wait between each retry
TryFunc is the function to try to execute.
It receives as arguments: - the number of this attempt '[0..len(BackoffArray]' - the limit of executions 'len(BackoffArray) + 1'