retry

package
v0.0.0-...-028f1de Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 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 ExponentialRetryer

type ExponentialRetryer struct {
	CallableFunc   func() (interface{}, error)
	GeometricRatio float64
	// a random amount of jitter up to JitterRatio percentage, 0.0 means no jitter, 0.15 means 15% added to the total wait time.
	JitterRatio         float64
	InitialDelayInMilli int
	MaxDelayInMilli     int
	MaxAttempts         int
}

TODO Move to a common package for retry and merge with HibernateRetryStrategy

func (*ExponentialRetryer) Call

func (retryer *ExponentialRetryer) Call() (channel interface{}, err error)

Call calls the operation and does exponential retry if error happens until it reaches MaxAttempts if specified.

func (*ExponentialRetryer) Init

func (retryer *ExponentialRetryer) Init()

Init initializes the retryer

func (*ExponentialRetryer) NextSleepTime

func (retryer *ExponentialRetryer) NextSleepTime(attempt int) (time.Duration, bool)

NextSleepTime calculates the next delay of retry. Returns next sleep time as well as if it reaches max delay

type Retryer

type Retryer interface {
	Call() error
	NextSleepTime(int32) time.Duration
}

Jump to

Keyboard shortcuts

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