db

package
v0.0.0-...-9c90d3e Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg *config.Config, logger lumber.Logger) (core.DB, error)

Connect create connection with database

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a pool of zero or more underlying connections to the neuron database.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Execute

func (db *DB) Execute(fn func(conn *sqlx.DB) error) (err error)

Execute and executes a function. Any error that is returned from the function is returned from the Execute() method.

func (*DB) ExecuteTransactionWithRetry

func (db *DB) ExecuteTransactionWithRetry(
	ctx context.Context,
	maxRetries uint,
	delay,
	maxJitter time.Duration,
	errorMsg string,
	fn func(tx *sqlx.Tx) error) (err error)

ExecuteTransactionWithRetry wrapper for executing queries in a transaction and retries the transaction if transaction deadlock or transaction timeout.

Jump to

Keyboard shortcuts

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