Documentation ¶
Index ¶
- Constants
- func Backoff(slotDuration time.Duration, ceiling uint, jitterLimit float64) backoff.Backoff
- func Check(err error) (m retryMode)
- func Do(ctx context.Context, db *sql.DB, ...) error
- func DoTx(ctx context.Context, db *sql.DB, op func(context.Context, *sql.Tx) error, ...) error
- func DoTxWithResult[T any](ctx context.Context, db *sql.DB, op func(context.Context, *sql.Tx) (T, error), ...) (T, error)
- func DoWithResult[T any](ctx context.Context, db *sql.DB, ...) (T, error)
- func IsOperationIdempotent(ctx context.Context) booldeprecated
- func Retry(ctx context.Context, op retryOperation, opts ...Option) (finalErr error)
- func RetryWithResult[T any](ctx context.Context, op func(context.Context) (T, error), opts ...Option) (_ T, finalErr error)
- func RetryableError(err error, opts ...retryableErrorOption) error
- func WithBackoff(t backoff.Type) retryableErrorOption
- func WithBudget(b budget.Budget) budgetOption
- func WithDeleteSession() retryableErrorOption
- func WithDoRetryOptions(opts ...Option) doRetryOptionsOption
- func WithDoTxRetryOptions(opts ...Option) doTxRetryOptionsOption
- func WithFastBackoff(b backoff.Backoff) fastBackoffOption
- func WithIdempotent(idempotent bool) idempotentOption
- func WithIdempotentOperation(ctx context.Context) context.Contextdeprecated
- func WithLabel(label string) labelOption
- func WithNonIdempotentOperation(ctx context.Context) context.Contextdeprecated
- func WithPanicCallback(panicCallback func(e interface{})) panicCallbackOption
- func WithSlowBackoff(b backoff.Backoff) slowBackoffOption
- func WithStackTrace() stackTraceOption
- func WithTrace(t *trace.Retry) traceOption
- func WithTxOptions(txOptions *sql.TxOptions) txOptionsOption
- type Option
Constants ¶
const ( TypeNoBackoff = backoff.TypeNoBackoff TypeFastBackoff = backoff.TypeFast TypeSlowBackoff = backoff.TypeSlow )
Variables ¶
This section is empty.
Functions ¶
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 DoTxWithResult ¶
func DoTxWithResult[T any](ctx context.Context, db *sql.DB, op func(context.Context, *sql.Tx) (T, error), opts ...doTxOption, ) (T, error)
DoTxWithResult is a retryer of database/sql transactions with fallbacks on errors
Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
func DoWithResult ¶
func DoWithResult[T any](ctx context.Context, db *sql.DB, op func(ctx context.Context, cc *sql.Conn) (T, error), opts ...doOption, ) (T, error)
DoWithResult is a retryer of database/sql Conn with fallbacks on errors
Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
func IsOperationIdempotent
deprecated
IsOperationIdempotent returns the flag for retry with no idempotent errors
Deprecated: context cannot store idempotent value now. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func Retry ¶
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 context without deadline or cancellation func was passed, Retry will work infinitely.
If you need to retry your op func on some logic errors - you must return RetryableError() from retryOperation ¶
func RetryWithResult ¶
func RetryWithResult[T any](ctx context.Context, op func(context.Context) (T, error), opts ...Option, ) (_ T, finalErr error)
RetryWithResult provide the best effort fo retrying operation which will return value or error
RetryWithResult 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 context without deadline or cancellation func was passed, RetryWithResult will work infinitely.
If you need to retry your op func on some logic errors - you must return RetryableError() from retryOperation ¶
Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
func RetryableError ¶
RetryableError makes retryable error from options RetryableError provides retrying on custom errors
func WithBackoff ¶
WithBackoff makes retryable error option with custom backoff type
func WithBudget ¶
WithBudget returns budget option
Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
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 explicit options instead. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func WithDoTxRetryOptions ¶
func WithDoTxRetryOptions(opts ...Option) doTxRetryOptionsOption
WithDoTxRetryOptions specified retry options Deprecated: use explicit options instead. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func WithFastBackoff ¶
WithFastBackoff replaces default fast backoff
func WithIdempotent ¶
func WithIdempotent(idempotent bool) idempotentOption
WithIdempotent applies idempotent flag to retry operation
func WithIdempotentOperation
deprecated
WithIdempotentOperation returns a copy of parent context with idempotent operation feature
Deprecated: use retry.WithIdempotent option instead. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func WithLabel ¶
func WithLabel(label string) labelOption
WithLabel applies label for identification call Retry in trace.Retry.OnRetry
func WithNonIdempotentOperation
deprecated
WithNonIdempotentOperation returns a copy of parent context with non-idempotent operation feature
Deprecated: idempotent flag is false by default. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
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 ¶
WithSlowBackoff replaces default slow backoff
func WithStackTrace ¶
func WithStackTrace() stackTraceOption
WithStackTrace wraps errors with stacktrace from Retry call
func WithTxOptions ¶
WithTxOptions specified transaction options