backoffutil

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package backoffutil provides a wrapper above github.com/cenk/backoff.Retry that checks the error returned and only retries retryable errors.

For the sake of simplicity, the backoff strategy is the default exponential backoff.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(fn func() error) error

Retry does exponential backoff. Backoff will trigger if an error is returned, implements Retryabler AND the error is retryable.

Example
Retry(func() error {
	resp, err := http.Get("http://www.example.com")
	if err != nil {
		return errorutil.RetryableError(err)
	}
	defer resp.Body.Close()
	if err := errorutil.HTTPError(resp); err != nil {
		return err
	}
	// Do something
	return nil
})
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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