util

package
v0.0.0-...-3979f71 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMetastate

func GetMetastate(ctx context.Context, db *pgxpool.Pool, tx pgx.Tx, key string) (string, error)

GetMetastate returns `idb.ErrorNotInitialized` if uninitialized. If `tx` is nil, it uses a normal query.

func SetMetastate

func SetMetastate(db *pgxpool.Pool, tx pgx.Tx, key, jsonStrValue string) error

SetMetastate sets metastate. If `tx` is nil, it uses a normal query.

func TxWithRetry

func TxWithRetry(db *pgxpool.Pool, opts pgx.TxOptions, f func(pgx.Tx) error, log *log.Logger) error

TxWithRetry is a helper function that retries the function `f` in case the database transaction in it fails due to a serialization error. `f` is provided a transaction created using `opts`. If `f` experiences a database error, this error must be included in `f`'s return error's chain, so that a serialization error can be detected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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