retry

package
Version: v0.0.0-...-f4b3689 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package retry implements back off retry strategy for session manager channel connection.

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
	NonRetryableErrors  []string
}

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
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL