retry

package
v0.1.75 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BaseDelay = 10        // base delay is 10ms
	MaxDelay  = 60 * 1000 // max delay is 60s
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DecorRelatedJitter

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

DecorRelatedJitter 去相关抖动退避 delay = min(最大等待时间, random(基础等待时间, 基础等待时间 * 3);

func NewDecorRelatedJitter added in v0.1.40

func NewDecorRelatedJitter() *DecorRelatedJitter

func (*DecorRelatedJitter) ComputeDelayBeforeNextRetry

func (d *DecorRelatedJitter) ComputeDelayBeforeNextRetry(int32) int32

func (DecorRelatedJitter) GetBaseDelay added in v0.1.40

func (s DecorRelatedJitter) GetBaseDelay() int32

func (DecorRelatedJitter) SetBaseDelay added in v0.1.40

func (s DecorRelatedJitter) SetBaseDelay(baseDelay int32)

type EqualJitter

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

EqualJitter 等抖动指数退避 delay = Exponential/2 + random(0, Exponential/2)

func NewEqualJitter added in v0.1.40

func NewEqualJitter() *EqualJitter

func (*EqualJitter) ComputeDelayBeforeNextRetry

func (e *EqualJitter) ComputeDelayBeforeNextRetry(retryTimes int32) int32

func (EqualJitter) GetBaseDelay added in v0.1.40

func (s EqualJitter) GetBaseDelay() int32

func (EqualJitter) SetBaseDelay added in v0.1.40

func (s EqualJitter) SetBaseDelay(baseDelay int32)

type Exponential

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

Exponential 指数退避 delay = min(最大等待时间, 基础等待时间 * (2^已重试次数))

func NewExponential added in v0.1.40

func NewExponential() *Exponential

func (*Exponential) ComputeDelayBeforeNextRetry

func (e *Exponential) ComputeDelayBeforeNextRetry(retryTimes int32) int32

func (Exponential) GetBaseDelay added in v0.1.40

func (s Exponential) GetBaseDelay() int32

func (Exponential) SetBaseDelay added in v0.1.40

func (s Exponential) SetBaseDelay(baseDelay int32)

type None

type None struct{}

func (None) ComputeDelayBeforeNextRetry

func (n None) ComputeDelayBeforeNextRetry(int32) int32

func (None) SetBaseDelay added in v0.1.40

func (n None) SetBaseDelay(int32)

type RandomJitter

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

RandomJitter 全抖动指数退避 delay = random(0, Exponential)

func NewRandomJitter added in v0.1.40

func NewRandomJitter() *RandomJitter

func (*RandomJitter) ComputeDelayBeforeNextRetry

func (r *RandomJitter) ComputeDelayBeforeNextRetry(retryTimes int32) int32

func (RandomJitter) GetBaseDelay added in v0.1.40

func (s RandomJitter) GetBaseDelay() int32

func (RandomJitter) SetBaseDelay added in v0.1.40

func (s RandomJitter) SetBaseDelay(baseDelay int32)

type Strategy

type Strategy interface {
	SetBaseDelay(int32)
	ComputeDelayBeforeNextRetry(int32) int32
}

Jump to

Keyboard shortcuts

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