retry-go: Index | Files | Directories

package retry

import ""


Package Files


func Do Uses

func Do(fn Func, retries int, sleep time.Duration) error

Do runs the passed function until the number of retries is reached. Whenever Func returns err it will sleep and Func will be executed again in a recursive fashion. The sleep value is slightly modified on every retry (exponential backoff) to prevent the thundering herd problem ( If no value is given to sleep it will defaults to 500ms.

func DoHTTP Uses

func DoHTTP(fn HTTPFunc, retries int, sleep time.Duration) (*http.Response, error)

DoHTTP wraps Func and returns *http.Response and error as returning arguments.

type Func Uses

type Func func() error

Func is the function to be executed and eventually retried.

type HTTPFunc Uses

type HTTPFunc func() (*http.Response, error)

HTTPFunc is the function to be executed and eventually retried. The only difference from Func is that it expects an *http.Response on the first returning argument.



Package retry imports 3 packages (graph) and is imported by 7 packages. Updated 2017-12-14. Refresh now. Tools for package owners.