backoff

package
v7.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff interface {
	// Time 获取重试的退避时长间隔
	Time(context.Context, *BackoffOptions) time.Duration
}

Backoff 退避器接口

func NewBackoff

func NewBackoff(fn func(context.Context, *BackoffOptions) time.Duration) Backoff

NewBackoff 创建自定义时长的退避器

func NewExponentialBackoff

func NewExponentialBackoff(wait time.Duration, baseNumber int64) Backoff

NewExponentialBackoff 创建时长指数级增长的退避器

func NewFixedBackoff

func NewFixedBackoff(wait time.Duration) Backoff

NewFixedBackoff 创建固定时长的退避器

func NewLimitedBackoff

func NewLimitedBackoff(base Backoff, min, max time.Duration) Backoff

NewLimitedBackoff 创建限制时长的退避器

func NewRandomizedBackoff

func NewRandomizedBackoff(base Backoff, minification, magnification rational.Rational) Backoff

NewRandomizedBackoff 创建随机时长的退避器

type BackoffOptions

type BackoffOptions struct {
	// Attempts 重试次数
	Attempts int
}

BackoffOptions 退避器选项

Jump to

Keyboard shortcuts

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