transaction

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketFsClientCreator added in v0.5.3

type BucketFsClientCreator func() (bfs.BucketFsAPI, error)

BucketFsClientCreator creates a new bfs.BucketFsAPI. It allows injecting a mock BucketFS client in unit tests.

type TransactionContext

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

TransactionContext contains the state of a running database transaction.

func BeginTransaction

func BeginTransaction(ctx context.Context, db *sql.DB, bucketFsBasePath string) (*TransactionContext, error)

BeginTransaction starts a new database transaction.

func (*TransactionContext) Commit

func (ctx *TransactionContext) Commit() error

Commit commits the transaction and cleans up any resources like the bfs.BucketFsAPI if one was created.

func (*TransactionContext) GetBucketFsClient added in v0.5.3

func (ctx *TransactionContext) GetBucketFsClient() (bfs.BucketFsAPI, error)

GetBucketFsClient returns a bfs.BucketFsAPI. This creates a new client if none exists yet or returns the existing one.

func (*TransactionContext) GetContext

func (ctx *TransactionContext) GetContext() context.Context

GetContext returns the current context.Context.

func (*TransactionContext) GetDBConnection

func (ctx *TransactionContext) GetDBConnection() *sql.DB

GetDBConnection returns the current database connection.

func (*TransactionContext) GetTransaction

func (ctx *TransactionContext) GetTransaction() *sql.Tx

GetTransaction returns the current database transaction.

func (*TransactionContext) Rollback

func (ctx *TransactionContext) Rollback()

Rollback rolls back the transaction and cleans up any resources like the bfs.BucketFsAPI if one was created.

type TransactionStarter added in v0.5.3

type TransactionStarter func(ctx context.Context, db *sql.DB, bucketFsBasePath string) (*TransactionContext, error)

TransactionStarter starts a database transaction and returns a new TransactionContext. It allows injecting a mock transaction in unit tests.

type TransactionStarterMock added in v0.5.3

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

func CreateTransactionStarterMock added in v0.5.3

func CreateTransactionStarterMock(dbMock *sql.DB, bfsMock *bfs.BucketFsMock) *TransactionStarterMock

func (*TransactionStarterMock) GetTransactionStarter added in v0.5.3

func (m *TransactionStarterMock) GetTransactionStarter() TransactionStarter

func (*TransactionStarterMock) SimulateMockTransaction added in v0.5.3

func (m *TransactionStarterMock) SimulateMockTransaction()

func (*TransactionStarterMock) SimulateTransactionFailed added in v0.5.3

func (m *TransactionStarterMock) SimulateTransactionFailed(err error)

Jump to

Keyboard shortcuts

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