retry

package
v0.0.0-...-9351281 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIsRetryable

func DefaultIsRetryable(err error) bool

DefaultIsRetryable returns true if the error is caused by a network or connection error

func ExpBackoff

func ExpBackoff(opts ...backoff.ExponentialBackOffOpts) func() time.Duration

ExpBackoff returns an exponential backoff duration based on cenkalti/backoff.

func ExpBackoffGenerator

func ExpBackoffGenerator() func() time.Duration

ExpBackoffGenerator returns an exponential backoff duration function

func FixedBackoff

func FixedBackoff() time.Duration

FixedBackoff returns a fixed backoff duration of 1 second.

func FixedBackoffGenerator

func FixedBackoffGenerator() func() time.Duration

FixedBackoffGenerator returns a fixed backoff duration function.

func NewRetryInterceptor

func NewRetryInterceptor(logger *slog.Logger, conf *RetryConfig) connect.UnaryInterceptorFunc

NewRetryInterceptor returns a new retry interceptor.

Types

type RetryConfig

type RetryConfig struct {
	// A BackoffGenerator returns an instance of a backoff function for use with a single RPC call.
	// By default, it returns a fixed backoff of 1 second between attempts.
	// When the backoff function returns backoff.Stop (-1ns), the RPC call will not be retried.
	BackoffGenerator func() func() time.Duration
	// IsRetryable should return true if the error is retryable.
	// By default, it returns true for connect.CodeUnavailable and common network errors.
	IsRetryable func(error) bool
	// Set max attempts to <= 0 to retry indefinitely.
	MaxAttempts int
}

RetryConfig contains the configuration for the retry interceptor

func DefaultRetryConfig

func DefaultRetryConfig() *RetryConfig

DefaultRetryConfig returns a default retry configuration with a fixed backoff and retries on common network errors.

Jump to

Keyboard shortcuts

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