Socket
Book a DemoInstallSign in
Socket

github.com/davidhuie/retries

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/davidhuie/retries

Source
Go
Version
v0.0.0-20200228042244-02b1abf2d8eb
Version published
Created
Source

retries

A simple, extensible Go retries library.

Example

Without any arguments, the retrier uses the default strategy of using exponential back-off, four retries, and retrying on all errors.

myFunc := func() error {
	return errors.New("error")
}

retrier := New(myFunc)
if err := retrier.Try(); err != nil {
	log.Println(err)
}

All of the parameters in the default strategy can also be customized.

myErr := errors.New("error")

myFunc := func() error {
	return myErr
}

retrier := New(
	myFunc,
	WithRetries(10),
	WithWhitelist(myErr),
	WithExpBackoff(2),
)
if err := retrier.Try(); err != nil {
	log.Println(err)
}

FAQs

Package last updated on 28 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts