retry

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	BackoffTypeNoBackoff   = errors.BackoffTypeNoBackoff
	BackoffTypeFastBackoff = errors.BackoffTypeFastBackoff
	BackoffTypeSlowBackoff = errors.BackoffTypeSlowBackoff
)

Variables

View Source
var (
	FastBackoff = newBackoff(
		withSlotDuration(fastSlot),
		withCeiling(6),
	)
	SlowBackoff = newBackoff(
		withSlotDuration(slowSlot),
		withCeiling(6),
	)
)

Default parameters used by Retry() functions within different sub packages.

Functions

func Check

func Check(err error) (m retryMode)

Check returns retry mode for err.

func IsOperationIdempotent

func IsOperationIdempotent(ctx context.Context) bool

IsOperationIdempotent returns the flag for retry with no idempotent errors

func Retry

func Retry(ctx context.Context, op retryOperation, opts ...retryOption) (err error)

Retry provide the best effort fo retrying operation Retry implements internal busy loop until one of the following conditions is met: - deadline was canceled or deadlined - retry operation returned nil as error Warning: if deadline without deadline or cancellation func Retry will be worked infinite If you need to retry your op func on some logic errors - you must return RetryableError() from retryOperation

func RetryableError added in v3.7.0

func RetryableError(err error, opts ...retryableErrorOption) error

func Wait

func Wait(ctx context.Context, fastBackoff Backoff, slowBackoff Backoff, m retryMode, i int) error

func WithBackoff added in v3.7.0

func WithBackoff(t errors.BackoffType) retryableErrorOption

func WithDeleteSession added in v3.7.0

func WithDeleteSession() retryableErrorOption

func WithID added in v3.10.0

func WithID(id string) retryOption

func WithIdempotent added in v3.10.0

func WithIdempotent() retryOption

WithIdempotent returns discovery trace option

func WithIdempotentOperation

func WithIdempotentOperation(ctx context.Context) context.Context

WithIdempotentOperation returns a copy of parent context with idempotent operation feature

func WithNonIdempotentOperation

func WithNonIdempotentOperation(ctx context.Context) context.Context

WithNonIdempotentOperation returns a copy of parent context with non-idempotent operation feature

func WithTrace added in v3.10.0

func WithTrace(trace trace.Retry) retryOption

WithTrace returns discovery trace option

Types

type Backoff

type Backoff interface {
	// Wait maps index of the retry to a channel which fulfillment means that
	// delay is over.
	//
	// Note that retry index begins from 0 and 0-th index means that it is the
	// first retry attempt after an initial error.
	Wait(n int) <-chan time.Time
}

Backoff is the interface that contains logic of delaying operation retry.

Jump to

Keyboard shortcuts

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