dbtxn

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKey for transactional context
	ContextKey key = iota
)

Variables

This section is empty.

Functions

func BaseRunner

func BaseRunner(ctx context.Context, defaultRuner sq.BaseRunner) sq.BaseRunner

BaseRunner of transaction

func Error

func Error(ctx context.Context) error

Error of transaction

func SetError

func SetError(ctx context.Context, err error) error

SetError to set error in ctx

func WithContext

func WithContext(parent context.Context) context.Context

WithContext with transaction

Types

type Context

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

Context of transaction

type Transactional

type Transactional struct {
	dig.In
	*typpostgres.DB
}

Transactional database

func (*Transactional) CancelMe

func (t *Transactional) CancelMe(ctx context.Context, err error) error

CancelMe is store error to context to trigger the rollback mechanism

func (*Transactional) CommitMe

func (t *Transactional) CommitMe(ctx *context.Context) func() error

CommitMe to create begin transaction and return commit function to be deffered

Jump to

Keyboard shortcuts

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