backoff

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Stop = backoff.Stop
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackOff

type BackOff = backoff.BackOff

BackOff type alias of "github.com/cenkalti/backoff/v4" BackOff, for better readability in importing

func NewBackoff

func NewBackoff(clk clock.Clock, interval time.Duration, opts ...Options) BackOff

NewBackoff returns a new backoff calculator ready for use. Generalizes all backoffs to have the same behavioral pattern, though with different bounds based on given interval.

type Options

type Options interface {
	// contains filtered or unexported methods
}

Option allows customization of the backoff.ExponentialBackOff

func WithMaxElapsedTime

func WithMaxElapsedTime(maxElapsedTime time.Duration) Options

WithMaxElapsedTime returns maxElapsedTime backoff option to override the MaxElapsedTime

func WithMaxInterval

func WithMaxInterval(maxInterval time.Duration) Options

WithMaxInterval returns maxInterval backoff option to override the MaxInterval

type SizeLimitedBackOff

type SizeLimitedBackOff interface {
	// NextBackOff returns the duration to wait before retrying the operation,
	// or backoff.
	NextBackOff() int

	// Success indicates the backoff implementation that previous request succeeded
	// so that it can adjust backoff accordingly for next request.
	Success()

	// Failure indicates the backoff implementation that previous request failed
	// so that it can adjust backoff accordingly for next request.
	Failure()

	// Reset to initial state.
	Reset()
}

SizeLimitedBackOff defines interface for implementing a size based backoff for requests which contain number of records to be processed by server.

func NewSizeLimitedBackOff

func NewSizeLimitedBackOff(maxRequestSize int) SizeLimitedBackOff

NewSizeLimitedBackOff returns a new SizeLimitedBackOff with provided maxRequestSize and lowest request size of 1. On Failure the size gets reduced by half and on Success size gets doubled

Jump to

Keyboard shortcuts

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