gotry

package
v0.2.46 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGotry          = xerror.NewXErr("Gotry")
	ErrNotFuncType    = ErrGotry.New("func type not match error")
	ErrParamsNotMatch = ErrGotry.New("params not match error")
	ErrRetry          = ErrGotry.New("retry error")
)
View Source
var (
	// RetryWaitTime retry basic wait time
	RetryWaitTime = 200 * time.Millisecond
	// RetryMaxWaitTime Maximum retry wait time
	RetryMaxWaitTime = 10 * time.Second
	// RetryAttempt number of retries
	RetryAttempt = 1
)
View Source
var (
	ErrRetryFail = errors.New("retry fail")
	ErrRetry     = errors.New("need to retry")
)
View Source
var IsDebug = xenv.IsDebug()

Functions

func Retry

func Retry(num int, fn func(i int)) (err error)

Retry error

func RetryAt

func RetryAt(t time.Duration, fn func(i int))

RetryAt error

func Ticker

func Ticker(fn func(i int) time.Duration)

Ticker error

func Try

func Try(fn interface{}) func(...interface{}) func(...interface{}) (err error)

Try xerror

func TryRaw

func TryRaw(fn reflect.Value) func(...reflect.Value) func(...reflect.Value) (err error)

TryRaw xerror

Types

type Retry

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

Retry is the core data structure of the retry function https://amazonaws-china.com/cn/blogs/architecture/exponential-backoff-and-jitter/

func (*Retry) Attempt added in v0.2.45

func (r *Retry) Attempt(attempt int) dataflow.Retry

Attempt set the number of retries

func (*Retry) Do added in v0.2.45

func (r *Retry) Do() (err error)

Do send function

func (*Retry) Func added in v0.2.45

func (r *Retry) Func(cb func(c *dataflow.Context) error) dataflow.Retry

func (*Retry) MaxWaitTime added in v0.2.45

func (r *Retry) MaxWaitTime(maxWaitTime time.Duration) dataflow.Retry

MaxWaitTime Sets the maximum wait time

func (*Retry) New added in v0.2.45

func (r *Retry) New(df *dataflow.DataFlow) interface{}

func (*Retry) WaitTime added in v0.2.45

func (r *Retry) WaitTime(waitTime time.Duration) dataflow.Retry

WaitTime sets the basic wait time

Jump to

Keyboard shortcuts

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