retry

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Retry

type Retry interface {
	// Do execute work first, if execute failed, retry execute many times
	Do(f func() error, desc string) Wait
	// DoWithContext execute work first, if execute failed, retry execute many times, cancel retry with context
	DoWithContext(ctx context.Context, f func() error, desc string) Wait
	// RetryCount retry count
	RetryCount() int
	// RetryWait wait time after every retry to fail
	RetryWait() time.Duration
}

Retry if execute return error, then retry to execute with the specified rule

func NewRetry

func NewRetry(retryCount int, retryWait time.Duration, retryAsync bool) Retry

NewRetry get a default retry instance retryCount retry execute count retryWait execute once per retryWait interval retryAsync async or sync to execute retry

type Wait

type Wait interface {
	// Wait wait to the work execute finished
	Wait() error
}

type WaitDone

type WaitDone interface {
	Wait
	// Done mark the work execute finished
	Done()
	// DoneWithError mark the work execute finished with error info
	DoneWithError(err error)
}

WaitDone support execute the work synchronously

func NewWaitDone

func NewWaitDone() WaitDone

NewWaitDone create an instance of WaitOne to support execute the work synchronously

Jump to

Keyboard shortcuts

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