store

package
v0.0.0-...-a71e659 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const TransactionPerRequestKey ctxKeyTransaction = 0

RequestIDKey is the key that holds th unique request ID in a request context.

Variables

Providers are the wire providers for store

Functions

func GetTransactionFromContextOrCreate

func GetTransactionFromContextOrCreate(ctx context.Context, db *pg.DB) (*pg.Tx, error)

func NewDB

func NewDB(
	globalLogger hclog.Logger,
	startupConf conf.Startup,
) (*pg.DB, error)

NewDB Initialices the database

func NewTxPerRequestMiddleware

func NewTxPerRequestMiddleware(
	parentLogger hclog.Logger,
	txBuilder TransactionBuilder,
) func(next http.Handler) http.Handler

Types

type LazyTransaction

type LazyTransaction interface {
	HasTransaction() bool
	GetCurrent() (*pg.Tx, error)
	CommitIfNeeded() error
	RollbackIfNeeded() error
}

func GetTransactionFromContext

func GetTransactionFromContext(ctx context.Context) LazyTransaction

func NewLazyTransaction

func NewLazyTransaction(db *pg.DB) LazyTransaction

type TransactionBuilder

type TransactionBuilder interface {
	BuildLazyTransactionContext(ctx context.Context) (context.Context, LazyTransaction, error)
}

TransactionBuilder builds database transactions

func NewPostgreTransactionBuilder

func NewPostgreTransactionBuilder(db *pg.DB) TransactionBuilder

NewPostgreTransactionBuilder creates the builder implementation for PostgreSQL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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