Documentation ¶
Index ¶
- Constants
- func Backoff(slotDuration time.Duration, ceiling uint, jitterLimit float64) backoff.Backoff
- func Check(err error) (m retry.Mode)
- func DoTx(ctx context.Context, db *sql.DB, f TxOperationFunc, opts ...DoTxOption) error
- func IsOperationIdempotent(ctx context.Context) bool
- func Retry(ctx context.Context, op retryOperation, opts ...retryOption) (err error)
- func RetryableError(err error, opts ...retryableErrorOption) error
- func WithBackoff(t backoff.Type) retryableErrorOption
- func WithDeleteSession() retryableErrorOption
- func WithFastBackoff(b backoff.Backoff) retryOption
- func WithID(id string) retryOption
- func WithIdempotent(idempotent bool) retryOption
- func WithIdempotentOperation(ctx context.Context) context.Context
- func WithNonIdempotentOperation(ctx context.Context) context.Context
- func WithPanicCallback(panicCallback func(e interface{})) retryOption
- func WithSlowBackoff(b backoff.Backoff) retryOption
- func WithStackTrace() retryOption
- func WithTrace(trace trace.Retry) retryOption
- type DoTxOption
- type TxOperationFunc
Constants ¶
const ( TypeNoBackoff = backoff.TypeNoBackoff TypeFastBackoff = backoff.TypeFast TypeSlowBackoff = backoff.TypeSlow )
Variables ¶
This section is empty.
Functions ¶
func DoTx ¶ added in v3.33.0
func DoTx(ctx context.Context, db *sql.DB, f TxOperationFunc, opts ...DoTxOption) error
DoTx is a shortcut for calling Do(ctx, f) on initialized TxDoer with DB field set to given db.
func IsOperationIdempotent ¶
IsOperationIdempotent returns the flag for retry with no idempotent errors Deprecated: context cannot store idempotent value now
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 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 ¶ added in v3.7.0
RetryableError makes retryable error from options RetryableError provides retrying on custom errors
func WithBackoff ¶ added in v3.7.0
WithBackoff makes retryable error option with custom backoff type
func WithDeleteSession ¶ added in v3.7.0
func WithDeleteSession() retryableErrorOption
WithDeleteSession makes retryable error option with delete session flag
func WithFastBackoff ¶ added in v3.15.0
WithFastBackoff replaces default fast backoff
func WithID ¶ added in v3.10.0
func WithID(id string) retryOption
WithID applies id for identification call Retry in trace.Retry.OnRetry
func WithIdempotent ¶ added in v3.10.0
func WithIdempotent(idempotent bool) retryOption
WithIdempotent applies idempotent flag to retry operation
func WithIdempotentOperation ¶
WithIdempotentOperation returns a copy of parent context with idempotent operation feature Deprecated: use retry.WithIdempotent option instead
func WithNonIdempotentOperation ¶
WithNonIdempotentOperation returns a copy of parent context with non-idempotent operation feature Deprecated: idempotent flag is false by default
func WithPanicCallback ¶ added in v3.18.3
func WithPanicCallback(panicCallback func(e interface{})) retryOption
WithPanicCallback returns panic callback option If not defined - panic would not intercept with driver
func WithSlowBackoff ¶ added in v3.15.0
WithSlowBackoff replaces default slow backoff
func WithStackTrace ¶ added in v3.24.1
func WithStackTrace() retryOption
WithStackTrace wraps errors with stacktrace from Retry call
Types ¶
type DoTxOption ¶ added in v3.33.0
type DoTxOption func(o *doTxOptions) error
DoTxOption defines option for redefine default DoTx behavior
func Idempotent ¶ added in v3.33.0
func Idempotent(idempotent bool) DoTxOption
Idempotent marked TxOperation as idempotent for best effort retrying
func WithTxOptions ¶ added in v3.33.0
func WithTxOptions(txOptions *sql.TxOptions) DoTxOption
WithTxOptions replaces default txOptions
func WithTxSettings ¶ added in v3.33.0
func WithTxSettings(txControl *table.TransactionSettings) DoTxOption
WithTxSettings makes driver.TxOptions by given txControl