retry

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2018 License: MIT Imports: 1 Imported by: 109

README

Retry

A simple retry package for Go.

Usage

Retry 10 times.

err := retry.Do(10, thisFunctionMayFail)
if err != nil {
  log.Fatal(err)
}

Retry with a delay.

err := retry.DoSleep(10, 3 * time.Second, thisFunctionMayFail)
if err != nil {
  log.Fatal(err)
}

Retry forever.

retry.DoForever(thisFunctionMayFail)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(n int, f RetryFunc) (err error)

Do retries calling function f n-times. It returns an error if none of the tries succeeds.

func DoSleep

func DoSleep(n int, d time.Duration, f RetryFunc) (err error)

DoSleep retries calling function f n-times and sleeps for d after each call. It returns an error if none of the tries succeeds.

func Forever

func Forever(f RetryFunc)

Forever keeps trying to call function f until it succeeds.

func ForeverSleep

func ForeverSleep(d time.Duration, f RetryFunc)

ForeverSleep keeps trying to call function f until it succeeds, and sleeps after each failure.

Types

type RetryFunc

type RetryFunc func(int) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL