retry

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package retry provides middlewares for retrying transient errors.

Example
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrPermanent is returned when the error should not be retried.
	ErrPermanent = errors.New("[xkafka/retry] permanent error")
)

Functions

func ExponentialBackoff

func ExponentialBackoff(opts ...Option) xkafka.MiddlewareFunc

ExponentialBackoff is a middleware with exponential backoff retry strategy. It retries the handler until the maximum number of retries or the maximum lifetime is reached. Default values: - MaxRetries: 100 - MaxDuration: 1 hour - Delay: 200 milliseconds - Jitter: 20 milliseconds - Multiplier: 1.5

Types

type Delay

type Delay time.Duration

Delay sets the delay between each retry.

type Jitter

type Jitter time.Duration

Jitter adds randomness to the delay between each retry.

type MaxDuration

type MaxDuration time.Duration

MaxDuration sets the maximum retry duration since the first execution.

type MaxRetries

type MaxRetries int

MaxRetries sets the maximum number of retries. ErrRetryLimitExceeded is returned after exhausting all retries.

type Multiplier

type Multiplier float64

Multiplier sets the exponential backoff multiplier.

type Option

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

Option configures the retry middleware.

Jump to

Keyboard shortcuts

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