Help us shape the future of Go! Take the 2026 Go Developer Survey

retry

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 2 Imported by: 50

README

retry

Build Status Coverage Status MIT License GoDoc

Description

retry N times

It is golang porting of perl's Sub::Retry

Synopsis

err := retry.Retry(3, 1*time.Second, func() error {
    // return error once in a while
})
if err != nil {
    // error handling
}

Author

Songmu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(n uint, interval time.Duration, fn func() error) (err error)

Retry calls the `fn` and if it returns the error, retry to call `fn` after `interval` duration. The `fn` is called up to `n` times.

func WithContext added in v0.1.0

func WithContext(ctx context.Context, n uint, interval time.Duration, fn func() error) (err error)

WithContext stops retrying when the context is done.

Types

This section is empty.

Directories

Path Synopsis
cmd
retry command

Jump to

Keyboard shortcuts

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