db

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	WithRetryableTransaction(ctx context.Context, f func(context.Context, *sql.Tx) error) error
	Close() error
}

type RDB

type RDB struct {
	DB *sql.DB
}

RDB wraps a *sql.DB and retries queries using an exponential backoff (with jitter) on lock_timeout errors.

func (*RDB) Close

func (db *RDB) Close() error

func (*RDB) ExecContext

func (db *RDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

ExecContext wraps sql.DB.ExecContext, retrying queries on lock_timeout errors.

func (*RDB) WithRetryableTransaction

func (db *RDB) WithRetryableTransaction(ctx context.Context, f func(context.Context, *sql.Tx) error) error

WithRetryableTransaction runs `f` in a transaction, retrying on lock_timeout errors.

Jump to

Keyboard shortcuts

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