retry

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2017 License: MIT Imports: 0 Imported by: 1

README

Retry library

Project status Build Status Coverage Status Go Report Card GoDoc License

Retry library provides a set of standardized common components and abstracts away some code that normally is duplicated. My motivation is not to reinvent the wheel but to standardize a set of components for reuse in other libraries.

Example

package main

import (
	"errors"
	"fmt"

	"github.com/go-playground/retry"
)

func main() {
	err := retry.Run(5, func() (bool, error) {
		return false, errors.New("ERR")
	},
		func(attempt uint16, err error) {
			fmt.Printf("Attempt: %d Error: %s\n", attempt, err)
		},
	)
	if err != nil {
		panic(err)
	}
}

Package Versioning

I'm jumping on the vendoring bandwagon, you should vendor this package as I will not be creating different version with gopkg.in like allot of my other libraries.

Why? because my time is spread pretty thin maintaining all of the libraries I have + LIFE, it is so freeing not to worry about it and will help me keep pouring out bigger and better things for you the community.

License

Distributed under MIT License, please see license file in code for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(max uint16, fn Fn, notifyFn NotifyFn) (err error)

Run retries the provided function the specified number of times

Types

type Fn

type Fn func() (bail bool, err error)

Fn is the retry function signature.

type NotifyFn

type NotifyFn func(attempt uint16, err error)

NotifyFn defines a function that is called upon each failed attempt.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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