util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package util contains common utility code for storage operations.

Index

Constants

This section is empty.

Variables

View Source
var Canceled context.Context

Canceled is an already-canceled context.

View Source
var ErrVersionSkew = errors.New("version skew")

ErrVersionSkew is returned from methods that operate on versioned data to indicate that the caller should refresh before retrying the operation.

Functions

func Retry

func Retry(ctx context.Context, idempotent func(context.Context) error) error

Retry is a convenience wrapper to automatically retry idempotent database operations that experience a transaction or or connection failure. The provided callback must be entirely idempotent, with no observable side-effects during its execution.

func RetryLoop

func RetryLoop(ctx context.Context, fn func(ctx context.Context, sideEffect *Marker) error) error

RetryLoop is a convenience wrapper to automatically retry idempotent database operations that experience a transaction or or connection failure. The provided callback may indicate that it has started generating observable effects (e.g. sending result data) by calling its second parameter to disable the retry behavior.

Types

type Marker

type Marker bool

Marker is a settable flag.

func (*Marker) Mark

func (m *Marker) Mark()

Mark sets the flag.

func (*Marker) Marked

func (m *Marker) Marked() bool

Marked returns the flag status.

Jump to

Keyboard shortcuts

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