retry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TODO(seukyaso): Consider adding some non-zero default retry options
	DefaultRetriableCodes = []codes.Code{codes.ResourceExhausted, codes.Unavailable}
)

Functions

func Interceptor deprecated

func Interceptor(callOpts ...grpc.CallOption) grpc.UnaryClientInterceptor

Interceptor returns retry interceptor, that can be parametrized by specific call options. Without any option, it uses default options, that basically retries nothing. Default retry quantity is 0, backoff function is nil, retry codes are DefaultRetriableCodes, AttemptHeader is false, and perCallTimeout is 0.

Deprecated: RetryDialOption function to provide standard gRPC retries. For idempotency keys use idempotency.Interceptor

func WithAttemptHeader deprecated

func WithAttemptHeader(enable bool) grpc.CallOption

WithAttemptHeader adds retry attempt number to context outgoing metadata, with key "x-retry-attempt".

Deprecated: use retry/v1 package instead of this options

func WithBackoff deprecated

func WithBackoff(f BackoffFunc) grpc.CallOption

WithBackoff sets up interceptor with custom defined backoff function

Deprecated: use retry/v1 package instead of this options

func WithCodes deprecated

func WithCodes(codes ...codes.Code) grpc.CallOption

WithCodes overrides the whole retriable codes list.

Deprecated: use retry/v1 package instead of this options

func WithDefaultInterceptor deprecated

func WithDefaultInterceptor() grpc.DialOption

WithDefaultInterceptor returns interceptor that DOESN'T retrу anything. Its possible to change its behaviour with call options.

Deprecated: use retry/v1 package instead of this options

func WithMax deprecated

func WithMax(maxRetryCount int) grpc.CallOption

WithMax option sets quantity of retry attempts. It handles negative maxRetryCount as INFINITE retries.

Deprecated: use retry/v1 package instead of this options

func WithPerCallTimeout deprecated

func WithPerCallTimeout(to time.Duration) grpc.CallOption

WithPerCallTimeout adds timeout for retry calls.

Deprecated: use retry/v1 package instead of this options

Types

type BackoffFunc

type BackoffFunc func(attempt int) time.Duration

func BackoffExponentialWithJitter

func BackoffExponentialWithJitter(base time.Duration, cap time.Duration) BackoffFunc

func BackoffLinearWithJitter

func BackoffLinearWithJitter(waitBetween time.Duration, jitterFraction float64) BackoffFunc

func DefaultBackoff deprecated

func DefaultBackoff() BackoffFunc

DefaultBackoff uses exponential backoff with jitter, with base = 50ms, and maximum timeout = 1 minute.

Deprecated: use retry/v1 package instead of this options

func DefaultExponentialJitterBackoff deprecated

func DefaultExponentialJitterBackoff() BackoffFunc

WithDefaultExponentialJitterBackoff same as WithDefaultBackoff

Deprecated: use retry/v1 package instead of this options

func DefaultLinearJitterBackoff deprecated

func DefaultLinearJitterBackoff() BackoffFunc

DefaultLinearJitterBackoff uses linear backoff with base = 50ms, and jitter = +-10%

Deprecated: use retry/v1 package instead of this options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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