transaction

package
v2.16.7-pre Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package transaction is a generated GoMock package.

Package transaction is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Begin

type Begin interface {
	// Begin transaction on the underlying transactable datastructure and
	// return it
	Begin() (Implementation, error)
}

Begin has methods for starting transactions

type Implementation

type Implementation interface {
	// NamedQuery within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	// NamedExec a named query within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	NamedExec(query string, arg interface{}) (sql.Result, error)
	// QueryRowx within a transaction.
	// Any placeholder parameters are replaced with supplied args.
	QueryRowx(query string, args ...interface{}) *sqlx.Row
	// Select within a transaction.
	// Any placeholder parameters are replaced with supplied args.
	Select(dest interface{}, query string, args ...interface{}) error
	// Exec a query within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	Exec(query string, args ...any) (sql.Result, error)
	// Commit this transaction
	Commit() error
	// Rollback this transaction
	Rollback() error
}

type MockImplementation

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

MockImplementation is a mock of Implementation interface.

func NewMockImplementation

func NewMockImplementation(ctrl *gomock.Controller) *MockImplementation

NewMockImplementation creates a new mock instance.

func (*MockImplementation) Commit

func (m *MockImplementation) Commit() error

Commit mocks base method.

func (*MockImplementation) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockImplementation) Exec

func (m *MockImplementation) Exec(query string, args ...any) (sql.Result, error)

Exec mocks base method.

func (*MockImplementation) NamedExec

func (m *MockImplementation) NamedExec(query string, arg interface{}) (sql.Result, error)

NamedExec mocks base method.

func (*MockImplementation) NamedQuery

func (m *MockImplementation) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)

NamedQuery mocks base method.

func (*MockImplementation) QueryRowx

func (m *MockImplementation) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx mocks base method.

func (*MockImplementation) Rollback

func (m *MockImplementation) Rollback() error

Rollback mocks base method.

func (*MockImplementation) Select

func (m *MockImplementation) Select(dest interface{}, query string, args ...interface{}) error

Select mocks base method.

type MockImplementationMockRecorder

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

MockImplementationMockRecorder is the mock recorder for MockImplementation.

func (*MockImplementationMockRecorder) Commit

Commit indicates an expected call of Commit.

func (*MockImplementationMockRecorder) Exec

func (mr *MockImplementationMockRecorder) Exec(query interface{}, args ...interface{}) *gomock.Call

Exec indicates an expected call of Exec.

func (*MockImplementationMockRecorder) NamedExec

func (mr *MockImplementationMockRecorder) NamedExec(query, arg interface{}) *gomock.Call

NamedExec indicates an expected call of NamedExec.

func (*MockImplementationMockRecorder) NamedQuery

func (mr *MockImplementationMockRecorder) NamedQuery(query, arg interface{}) *gomock.Call

NamedQuery indicates an expected call of NamedQuery.

func (*MockImplementationMockRecorder) QueryRowx

func (mr *MockImplementationMockRecorder) QueryRowx(query interface{}, args ...interface{}) *gomock.Call

QueryRowx indicates an expected call of QueryRowx.

func (*MockImplementationMockRecorder) Rollback

func (mr *MockImplementationMockRecorder) Rollback() *gomock.Call

Rollback indicates an expected call of Rollback.

func (*MockImplementationMockRecorder) Select

func (mr *MockImplementationMockRecorder) Select(dest, query interface{}, args ...interface{}) *gomock.Call

Select indicates an expected call of Select.

type MockTransaction

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

MockTransaction is a mock of Transaction interface.

func NewMockTransaction

func NewMockTransaction(ctrl *gomock.Controller) *MockTransaction

NewMockTransaction creates a new mock instance.

func (*MockTransaction) Commit

func (m *MockTransaction) Commit() errors.TracerError

Commit mocks base method.

func (*MockTransaction) Create

Create mocks base method.

func (*MockTransaction) Delete

Delete mocks base method.

func (*MockTransaction) DeleteWhere

DeleteWhere mocks base method.

func (*MockTransaction) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTransaction) Implementation

func (m *MockTransaction) Implementation() Implementation

Implementation mocks base method.

func (*MockTransaction) List

List mocks base method.

func (*MockTransaction) ListWhere

ListWhere mocks base method.

func (*MockTransaction) Read

Read mocks base method.

func (*MockTransaction) ReadOneWhere

func (m *MockTransaction) ReadOneWhere(arg0 record.Record, arg1 *qb.ConditionExpression) errors.TracerError

ReadOneWhere mocks base method.

func (*MockTransaction) Rollback

func (m *MockTransaction) Rollback() errors.TracerError

Rollback mocks base method.

func (*MockTransaction) Select

func (m *MockTransaction) Select(arg0 any, arg1 *qb.SelectQuery, arg2 record.ListOptions) errors.TracerError

Select mocks base method.

func (*MockTransaction) Update

Update mocks base method.

func (*MockTransaction) UpdateWhere

func (m *MockTransaction) UpdateWhere(arg0 record.Record, arg1 *qb.ConditionExpression, arg2 ...qb.FieldValue) (int64, errors.TracerError)

UpdateWhere mocks base method.

func (*MockTransaction) Upsert

Upsert mocks base method.

type MockTransactionMockRecorder

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

MockTransactionMockRecorder is the mock recorder for MockTransaction.

func (*MockTransactionMockRecorder) Commit

func (mr *MockTransactionMockRecorder) Commit() *gomock.Call

Commit indicates an expected call of Commit.

func (*MockTransactionMockRecorder) Create

func (mr *MockTransactionMockRecorder) Create(arg0 interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockTransactionMockRecorder) Delete

func (mr *MockTransactionMockRecorder) Delete(arg0 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockTransactionMockRecorder) DeleteWhere

func (mr *MockTransactionMockRecorder) DeleteWhere(arg0, arg1 interface{}) *gomock.Call

DeleteWhere indicates an expected call of DeleteWhere.

func (*MockTransactionMockRecorder) Implementation

func (mr *MockTransactionMockRecorder) Implementation() *gomock.Call

Implementation indicates an expected call of Implementation.

func (*MockTransactionMockRecorder) List

func (mr *MockTransactionMockRecorder) List(arg0, arg1, arg2 interface{}) *gomock.Call

List indicates an expected call of List.

func (*MockTransactionMockRecorder) ListWhere

func (mr *MockTransactionMockRecorder) ListWhere(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

ListWhere indicates an expected call of ListWhere.

func (*MockTransactionMockRecorder) Read

func (mr *MockTransactionMockRecorder) Read(arg0, arg1 interface{}) *gomock.Call

Read indicates an expected call of Read.

func (*MockTransactionMockRecorder) ReadOneWhere

func (mr *MockTransactionMockRecorder) ReadOneWhere(arg0, arg1 interface{}) *gomock.Call

ReadOneWhere indicates an expected call of ReadOneWhere.

func (*MockTransactionMockRecorder) Rollback

func (mr *MockTransactionMockRecorder) Rollback() *gomock.Call

Rollback indicates an expected call of Rollback.

func (*MockTransactionMockRecorder) Select

func (mr *MockTransactionMockRecorder) Select(arg0, arg1, arg2 interface{}) *gomock.Call

Select indicates an expected call of Select.

func (*MockTransactionMockRecorder) Update

func (mr *MockTransactionMockRecorder) Update(arg0 interface{}) *gomock.Call

Update indicates an expected call of Update.

func (*MockTransactionMockRecorder) UpdateWhere

func (mr *MockTransactionMockRecorder) UpdateWhere(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

UpdateWhere indicates an expected call of UpdateWhere.

func (*MockTransactionMockRecorder) Upsert

func (mr *MockTransactionMockRecorder) Upsert(arg0 interface{}) *gomock.Call

Upsert indicates an expected call of Upsert.

type Transaction

type Transaction interface {
	// Create initializes a Record and inserts it into the Database
	Create(record.Record) errors.TracerError
	// Upsert a new entry into the database for the Record
	Upsert(record.Record) errors.TracerError
	// Read populates a Record from the database
	Read(record.Record, record.PrimaryKeyValue) errors.TracerError
	// ReadOneWhere populates a Record from a custom where clause
	ReadOneWhere(record.Record, *qb.ConditionExpression) errors.TracerError
	// List populates obj with a list of Records from the database
	// TODO: [COR-586] we can expand the Record interface to return an collection
	// 		 of its type so we don't have to pass this clumsily
	List(record.Record, any, record.ListOptions) errors.TracerError
	// ListWhere populates target with a list of Records from the database
	// TODO: [COR-586] we can expand the Record interface to return a collection
	// 		 of its type so we don't have to pass this clumsily
	ListWhere(record.Record, any, *qb.ConditionExpression, record.ListOptions) errors.TracerError
	// Select executes a given select query and populates the target
	// TODO: [COR-586] we can expand the Record interface to return a collection
	// 		 of its type so we don't have to pass this clumsily
	Select(any, *qb.SelectQuery, record.ListOptions) errors.TracerError
	// Update replaces an entry in the database for the Record
	Update(record.Record) errors.TracerError
	// UpdateWhere updates fields for the Record based on a supplied where clause in a transaction
	UpdateWhere(record.Record, *qb.ConditionExpression, ...qb.FieldValue) (int64, errors.TracerError)
	// Delete removes a row from the database
	Delete(record.Record) errors.TracerError
	// DeleteWhere removes row(s) from the database based on a supplied where clause
	DeleteWhere(record.Record, *qb.ConditionExpression) errors.TracerError
	// Commit this transaction
	Commit() errors.TracerError
	// Rollback this transaction
	Rollback() errors.TracerError

	// Implementation that is backing this transaction
	Implementation() Implementation
}

Transaction is an in-progress database transaction.

A transaction must end with a call to Commit or Rollback.

After a call to Commit or Rollback, all operations on the transaction fail with ErrTxDone.

func New

func New(db Begin, logger log.Logger, slow time.Duration) (Transaction, error)

New transaction that will log query executions that are slower than the passed duration

Jump to

Keyboard shortcuts

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