Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(retryableFunc RetryableFunc, options ...Option) error
Do runs the function passed in parameter (retryableFunc) until the retry condition is fulfilled or until the context is Done. The following options are supported: - Retry condition: condition for retries to terminate (e.g. retryableFunc has not returned any error, max attempts...) - Retry trigger: trigger to continue in the next try (e.g. Delay, an system event...) - Context: context that can be used to terminate the function By default, these options are applied: - Retry condition: retryableFunc has not returned any error - Retry trigger: 10 milliseconds delay - Context: empty context
Types ¶
type Option ¶
type Option func(*Config)
func WithContext ¶
func WithDelay ¶
WithDelay sets a retry trigger with a 10 milliseconds delay WithDelay sets the retry trigger function.
func WithErrorIngnored ¶
func WithErrorIngnored() Option
WithErrorIngnored will not stop the loop if no error is returned by the retryable function. WithErrorIngnored sets the retry condition function.
func WithMaxAttempts ¶
WithMaxAttempts specifies the maximum number of attempts/retries If no error is returned by the retryable function, then the retries will finished before the number of max attempts is reached. WithMaxAttempts sets the retry condition function.
func WithRetryCondition ¶
func WithRetryCondition(retryCondition RetryCondition) Option
WithRetryCondition sets the retry condition function.
func WithRetryTrigger ¶
func WithRetryTrigger(retryTrigger RetryTrigger) Option
WithRetryTrigger sets the retry trigger function.
type RetryCondition ¶
RetryCondition is the function definition specifying if the Do function should continue in an new attempt or not.
type RetryTrigger ¶
RetryTrigger is the function definition specifying when the Do function should continue in an new attempt.
type RetryableFunc ¶
type RetryableFunc func() error
Function definition to be executed and retried.