package retry

import "github.com/ydb-platform/ydb-go-sdk/v3/retry"

Index

Constants

const (
	TypeNoBackoff   = backoff.TypeNoBackoff
	TypeFastBackoff = backoff.TypeFast
	TypeSlowBackoff = backoff.TypeSlow
)

Functions

func Backoff

func Backoff(slotDuration time.Duration, ceiling uint, jitterLimit float64) backoff.Backoff

Backoff makes backoff object with custom params

func Check

func Check(err error) (m retryMode)

Check returns retry mode for queryErr.

func Do

func Do(ctx context.Context, db *sql.DB, op func(ctx context.Context, cc *sql.Conn) error, opts ...doOption) error

Do is a retryer of database/sql Conn with fallbacks on errors

func DoTx

func DoTx(ctx context.Context, db *sql.DB, op func(context.Context, *sql.Tx) error, opts ...doTxOption) error

DoTx is a retryer of database/sql transactions with fallbacks on errors

func IsOperationIdempotent

func IsOperationIdempotent(ctx context.Context) bool

IsOperationIdempotent returns the flag for retry with no idempotent errors Deprecated: context cannot store idempotent value now

func Retry

func Retry(ctx context.Context, op retryOperation, opts ...Option) (finalErr error)

Retry provide the best effort fo retrying operation

Retry implements internal busy loop until one of the following conditions is met:

- context 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

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

RetryableError makes retryable error from options RetryableError provides retrying on custom errors

func WithBackoff

func WithBackoff(t backoff.Type) retryableErrorOption

WithBackoff makes retryable error option with custom backoff type

func WithDeleteSession

func WithDeleteSession() retryableErrorOption

WithDeleteSession makes retryable error option with delete session flag

func WithDoRetryOptions

func WithDoRetryOptions(opts ...Option) doRetryOptionsOption

WithDoRetryOptions specified retry options Deprecated: use implicit options instead

func WithDoTxRetryOptions

func WithDoTxRetryOptions(opts ...Option) doTxRetryOptionsOption

WithDoTxRetryOptions specified retry options Deprecated: use implicit options instead

func WithFastBackoff

func WithFastBackoff(b backoff.Backoff) fastBackoffOption

WithFastBackoff replaces default fast backoff

func WithIdempotent

func WithIdempotent(idempotent bool) idempotentOption

WithIdempotent applies idempotent flag to retry operation

func WithIdempotentOperation

func WithIdempotentOperation(ctx context.Context) context.Context

WithIdempotentOperation returns a copy of parent context with idempotent operation feature Deprecated: use retry.WithIdempotent option instead

func WithLabel

func WithLabel(label string) labelOption

WithLabel applies label for identification call Retry in trace.Retry.OnRetry

func WithNonIdempotentOperation

func WithNonIdempotentOperation(ctx context.Context) context.Context

WithNonIdempotentOperation returns a copy of parent context with non-idempotent operation feature Deprecated: idempotent flag is false by default

func WithPanicCallback

func WithPanicCallback(panicCallback func(e interface{})) panicCallbackOption

WithPanicCallback returns panic callback option If not defined - panic would not intercept with driver

func WithSlowBackoff

func WithSlowBackoff(b backoff.Backoff) slowBackoffOption

WithSlowBackoff replaces default slow backoff

func WithStackTrace

func WithStackTrace() stackTraceOption

WithStackTrace wraps errors with stacktrace from Retry call

func WithTrace

func WithTrace(t *trace.Retry) traceOption

WithTrace returns trace option

func WithTxOptions

func WithTxOptions(txOptions *sql.TxOptions) txOptionsOption

WithTxOptions specified transaction options

Types

type Option

type Option interface {
	ApplyRetryOption(opts *retryOptions)
}

Source Files

backoff.go context.go errors.go mode.go retry.go retryable_error.go sql.go

Version
v3.62.0
Published
Apr 4, 2024
Platform
windows/amd64
Imports
11 packages
Last checked
2 minutes ago

Tools for package owners.