retry

package
v0.0.0-...-1679dbc Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestBackOffExecute

func TestBackOffExecute() bool

TestBackOffExecute Only used for test.

Types

type Backoffer

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

Backoffer is a backoff policy for retrying operations.

func InitialBackoffer

func InitialBackoffer(base, max, total time.Duration, opts ...Option) *Backoffer

InitialBackoffer make the initial state for retrying.

  • `base` defines the initial time interval to wait before each retry.
  • `max` defines the max time interval to wait before each retry.
  • `total` defines the max total time duration cost in retrying. If it's 0, it means infinite retry until success.

func (*Backoffer) Exec

func (bo *Backoffer) Exec(
	ctx context.Context,
	fn func() error,
) error

Exec is a helper function to exec backoff.

func (*Backoffer) SetRetryableChecker

func (bo *Backoffer) SetRetryableChecker(checker func(err error) bool)

SetRetryableChecker sets the retryable checker.

type Option

type Option func(*Backoffer)

Option is used to customize the backoffer.

Jump to

Keyboard shortcuts

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