retry

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package retry is for executing a function repeatedly until it was successful or canceled by the context.

Index

Constants

View Source
const (
	// DefaultRetryTimes times of retry
	DefaultRetryTimes = 5
	// DefaultRetryDuration time duration of two retries
	DefaultRetryDuration = time.Second * 3
)

Variables

This section is empty.

Functions

func Retry

func Retry(retryFunc RetryFunc, opts ...Option) error

Retry executes the retryFunc repeatedly until it was successful or canceled by the context The default times of retries is 5 and the default duration between retries is 3 seconds

Types

type Option

type Option func(*RetryConfig)

Option is for adding retry config

func Context

func Context(ctx context.Context) Option

Context set retry context config

func RetryDuration

func RetryDuration(d time.Duration) Option

RetryDuration set duration of retries

func RetryTimes

func RetryTimes(n uint) Option

RetryTimes set times of retry

type RetryConfig

type RetryConfig struct {
	// contains filtered or unexported fields
}

RetryConfig is config for retry

type RetryFunc

type RetryFunc func() error

RetryFunc is function that retry executes

Jump to

Keyboard shortcuts

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