Documentation
¶
Overview ¶
Package retry ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(fn RetriableFunc, opts ...Option) error
Do retries the execution of the given function until it finishes successfully, it returns a nil error, or a timeout is reached.
If the function returns a non-nil error, a delay will be applied before executing the onRetry function on the error and retrying the function.
Types ¶
type OnRetryFunc ¶
type OnRetryFunc func(err error)
OnRetryFunc is executed after a RetrieableFunc fails and receives the returned error as argument.
type Option ¶
type Option func(*config)
Option to be applied to the retry config.
func OnRetry ¶
func OnRetry(fn OnRetryFunc) Option
OnRetry sets a new function to be applied to the error returned by the function execution.
type RetriableFunc ¶
type RetriableFunc func() error
RetriableFunc is a function to be retried in order to get a successful execution. In general this are functions which success depend on external conditions that can eventually be met.