retry

package
v0.0.0-...-d674cee Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoJitter makes the backoff sequence strict exponential.
	NoJitter = 1 + iota
	// FullJitter applies random factors to strict exponential.
	FullJitter
	// EqualJitter is also randomized, but prevents very short sleeps.
	EqualJitter
	// DecorrJitter increases the maximum jitter based on the last random value.
	DecorrJitter
)
View Source
const (
	GcOneRegionMaxBackoff   = 20000
	GcResolveLockMaxBackoff = 100000

	RawkvMaxBackoff = 20000
)

Maximum total sleep time(in ms) for kv/cop commands.

Variables

View Source
var CommitMaxBackoff = 41000

CommitMaxBackoff is max sleep time of the 'commit' command

Functions

func NewBackoffFn

func NewBackoffFn(base, cap, jitter int) func(ctx context.Context) int

NewBackoffFn creates a backoff func which implements exponential backoff with optional jitters. See http://www.awsarchitectureblog.com/2015/03/backoff.html

Types

type BackoffType

type BackoffType int

BackoffType is the retryable error type.

const (
	BoTiKVRPC BackoffType = iota
	BoTxnLock
	BoTxnLockFast
	BoPDRPC
	BoRegionMiss
	BoUpdateLeader
	BoServerBusy
)

Back off types.

func (BackoffType) String

func (t BackoffType) String() string

type Backoffer

type Backoffer struct {
	// contains filtered or unexported fields
}

Backoffer is a utility for retrying queries.

func NewBackoffer

func NewBackoffer(ctx context.Context, maxSleep int) *Backoffer

NewBackoffer creates a Backoffer with maximum sleep time(in ms).

func (*Backoffer) Backoff

func (b *Backoffer) Backoff(typ BackoffType, err error) error

Backoff sleeps a while base on the BackoffType and records the error message. It returns a retryable error if total sleep time exceeds maxSleep.

func (*Backoffer) Clone

func (b *Backoffer) Clone() *Backoffer

Clone creates a new Backoffer which keeps current Backoffer's sleep time and errors, and shares current Backoffer's context.

func (*Backoffer) Fork

func (b *Backoffer) Fork() (*Backoffer, context.CancelFunc)

Fork creates a new Backoffer which keeps current Backoffer's sleep time and errors, and holds a child context of current Backoffer's context.

func (*Backoffer) GetContext

func (b *Backoffer) GetContext() context.Context

GetContext returns the associated context.

func (*Backoffer) String

func (b *Backoffer) String() string

Jump to

Keyboard shortcuts

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