Documentation ¶
Index ¶
- Variables
- func CheckNoRows(inErr, outErr error) error
- func CheckUniqueViolation(inErr, outErr error) error
- func ExecuteInTx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, ...) (err error)
- func ExecuteRetryable(fn func() error) error
- func ExecuteTxWithinCtx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, ...) error
- func IsUniqueViolation(err error) bool
- func NewWithAwsIam(username, hostname, port, dbname string, config aws.Config) (*sql.DB, error)
- func NewWithUsernameAndPassword(username, password, hostname, port, dbname string) (*sql.DB, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyInTx = errors.New("already executing in existing db tx") ErrNotInTx = errors.New("not executing in existing db tx") )
Functions ¶
func CheckNoRows ¶
func CheckUniqueViolation ¶
func ExecuteInTx ¶
func ExecuteInTx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, fn func(tx *sqlx.Tx) error) (err error)
ExecuteInTx is meant for DB store implementations to execute an operation within the scope of a DB transaction. This method is aware of ExecuteTxWithinCtx, and will dynamically decide when to use a new or existing transaction, as well as where the respnosibilty for commit/rollback calls lie.
func ExecuteRetryable ¶
ExecuteRetryable Retry functions that perform non-transactional database operations.
func ExecuteTxWithinCtx ¶
func ExecuteTxWithinCtx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, fn func(context.Context) error) error
ExecuteTxWithinCtx executes a DB transaction that's scoped to a call to fn. The transaction is passed along with the context. Once fn is complete, commit/rollback is called based on whether an error is returned.
func IsUniqueViolation ¶
func NewWithAwsIam ¶
Get a DB connection pool using AWS IAM credentials
func NewWithUsernameAndPassword ¶
Get a DB connection pool using username/password credentials