retry

package
v0.0.0-...-7b544e9 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

retry implements back off retry strategy for reconnect web socket connection.

retry implements back off retry strategy for reconnect web socket connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(log log.T, attempts int, sleep time.Duration, fn func() error) (err error)

Retry implements back off retry strategy for reconnect web socket connection.

Types

type RepeatableExponentialRetryer

type RepeatableExponentialRetryer struct {
	CallableFunc        func() error
	GeometricRatio      float64
	InitialDelayInMilli int
	MaxDelayInMilli     int
	MaxAttempts         int
}

func (*RepeatableExponentialRetryer) Call

func (retryer *RepeatableExponentialRetryer) Call() (err error)

Call calls the operation and does exponential retry if error happens.

func (*RepeatableExponentialRetryer) NextSleepTime

func (retryer *RepeatableExponentialRetryer) NextSleepTime(attempt int) time.Duration

NextSleepTime calculates the next delay of retry.

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