transactional

package
v0.0.0-...-48b859a Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithDb

func ContextWithDb(ctx context.Context, db *pg.DB) context.Context

ContextWithDb sets Db to context request

func ContextWithTx

func ContextWithTx(ctx context.Context, tx *pg.Tx) context.Context

ContextWithTx sets Tx to context request

func ContextWithValue

func ContextWithValue(ctx context.Context, keyName string, value interface{}) context.Context

ContextWithValue sets Value to context request

func DbFromContext

func DbFromContext(ctx context.Context) *pg.DB

DbFromContext retrives Db from context

func Execute

func Execute(ctx context.Context, execFunc ExecFunc) error

Execute executes ExecFunc in transaction

func ExecuteWithPropagation

func ExecuteWithPropagation(ctx context.Context, propagation Propagation, execFunc ExecFunc) error

ExecuteWithPropagation executes ExecFunc in transaction with specific propagation

func TxFromContext

func TxFromContext(ctx context.Context) *pg.Tx

TxFromContext retrives Tx from context

func ValueFromContext

func ValueFromContext(ctx context.Context, keyName string) interface{}

ValueFromContext retrives Value from context

Types

type ExecFunc

type ExecFunc func(ctx context.Context, tx *pg.Tx) error

ExecFunc definition

type Propagation

type Propagation string

Propagation type

const (
	// Current supports a current transaction, creates a new one if none exists.
	Current Propagation = "Current"

	// Mandatory needs a current transaction, return an exception if none exists
	Mandatory Propagation = "Mandatory"

	// Savepoint supports a current transaction, creates a new one if none exists, creates savepoint and never return propagation error
	Savepoint Propagation = "Savepoint"
)

Jump to

Keyboard shortcuts

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