Documentation
¶
Index ¶
- Constants
- func NewModule(poolName string) fx.Option
- func NewPool(cfg *pgxpool.Config) (*pgxpool.Pool, error)
- func NewTracerBatch() pgx.BatchTracer
- func NewTracerConnect() pgx.ConnectTracer
- func NewTracerCopyFrom() pgx.CopyFromTracer
- func NewTracerPrepare() pgx.PrepareTracer
- func NewTracerQuery() pgx.QueryTracer
- func RegisterLifecycle(lc fx.Lifecycle, plc *Lifecycle)
- func RegisterTracer(tr *Tracer, cfg *pgxpool.Config)
- type Lifecycle
- type MockTransactional
- type MockTransactional_BeginTx_Call
- func (_c *MockTransactional_BeginTx_Call) Return(tx pgx.Tx, err error) *MockTransactional_BeginTx_Call
- func (_c *MockTransactional_BeginTx_Call) Run(run func(ctx context.Context, txOptions pgx.TxOptions)) *MockTransactional_BeginTx_Call
- func (_c *MockTransactional_BeginTx_Call) RunAndReturn(run func(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)) *MockTransactional_BeginTx_Call
- type MockTransactional_Expecter
- type MockTx
- func (_mock *MockTx) Begin(ctx context.Context) (pgx.Tx, error)
- func (_mock *MockTx) Commit(ctx context.Context) error
- func (_mock *MockTx) Conn() *pgx.Conn
- func (_mock *MockTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (_m *MockTx) EXPECT() *MockTx_Expecter
- func (_mock *MockTx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
- func (_mock *MockTx) LargeObjects() pgx.LargeObjects
- func (_mock *MockTx) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
- func (_mock *MockTx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (_mock *MockTx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
- func (_mock *MockTx) Rollback(ctx context.Context) error
- func (_mock *MockTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
- type MockTx_Begin_Call
- type MockTx_Commit_Call
- type MockTx_Conn_Call
- type MockTx_CopyFrom_Call
- type MockTx_Exec_Call
- type MockTx_Expecter
- func (_e *MockTx_Expecter) Begin(ctx interface{}) *MockTx_Begin_Call
- func (_e *MockTx_Expecter) Commit(ctx interface{}) *MockTx_Commit_Call
- func (_e *MockTx_Expecter) Conn() *MockTx_Conn_Call
- func (_e *MockTx_Expecter) CopyFrom(ctx interface{}, tableName interface{}, columnNames interface{}, ...) *MockTx_CopyFrom_Call
- func (_e *MockTx_Expecter) Exec(ctx interface{}, sql interface{}, arguments ...interface{}) *MockTx_Exec_Call
- func (_e *MockTx_Expecter) LargeObjects() *MockTx_LargeObjects_Call
- func (_e *MockTx_Expecter) Prepare(ctx interface{}, name interface{}, sql interface{}) *MockTx_Prepare_Call
- func (_e *MockTx_Expecter) Query(ctx interface{}, sql interface{}, args ...interface{}) *MockTx_Query_Call
- func (_e *MockTx_Expecter) QueryRow(ctx interface{}, sql interface{}, args ...interface{}) *MockTx_QueryRow_Call
- func (_e *MockTx_Expecter) Rollback(ctx interface{}) *MockTx_Rollback_Call
- func (_e *MockTx_Expecter) SendBatch(ctx interface{}, b interface{}) *MockTx_SendBatch_Call
- type MockTx_LargeObjects_Call
- type MockTx_Prepare_Call
- func (_c *MockTx_Prepare_Call) Return(statementDescription *pgconn.StatementDescription, err error) *MockTx_Prepare_Call
- func (_c *MockTx_Prepare_Call) Run(run func(ctx context.Context, name string, sql string)) *MockTx_Prepare_Call
- func (_c *MockTx_Prepare_Call) RunAndReturn(...) *MockTx_Prepare_Call
- type MockTx_QueryRow_Call
- func (_c *MockTx_QueryRow_Call) Return(row pgx.Row) *MockTx_QueryRow_Call
- func (_c *MockTx_QueryRow_Call) Run(run func(ctx context.Context, sql string, args ...any)) *MockTx_QueryRow_Call
- func (_c *MockTx_QueryRow_Call) RunAndReturn(run func(ctx context.Context, sql string, args ...any) pgx.Row) *MockTx_QueryRow_Call
- type MockTx_Query_Call
- func (_c *MockTx_Query_Call) Return(rows pgx.Rows, err error) *MockTx_Query_Call
- func (_c *MockTx_Query_Call) Run(run func(ctx context.Context, sql string, args ...any)) *MockTx_Query_Call
- func (_c *MockTx_Query_Call) RunAndReturn(run func(ctx context.Context, sql string, args ...any) (pgx.Rows, error)) *MockTx_Query_Call
- type MockTx_Rollback_Call
- type MockTx_SendBatch_Call
- func (_c *MockTx_SendBatch_Call) Return(batchResults pgx.BatchResults) *MockTx_SendBatch_Call
- func (_c *MockTx_SendBatch_Call) Run(run func(ctx context.Context, b *pgx.Batch)) *MockTx_SendBatch_Call
- func (_c *MockTx_SendBatch_Call) RunAndReturn(run func(ctx context.Context, b *pgx.Batch) pgx.BatchResults) *MockTx_SendBatch_Call
- type Tracer
- type Transactional
- type TxFunc
- type TxManager
Constants ¶
const ( DefaultDSNKey = "PG_DSN" DefaultDSN = `postgres://postgres:postgres@localhost:5432/postgres` )
Variables ¶
This section is empty.
Functions ¶
func NewTracerBatch ¶
func NewTracerBatch() pgx.BatchTracer
func NewTracerConnect ¶
func NewTracerConnect() pgx.ConnectTracer
ConnectTracer traces Connect and ConnectConfig.
func NewTracerCopyFrom ¶
func NewTracerCopyFrom() pgx.CopyFromTracer
func NewTracerPrepare ¶
func NewTracerPrepare() pgx.PrepareTracer
func NewTracerQuery ¶
func NewTracerQuery() pgx.QueryTracer
QueryTracer traces Query, QueryRow, and Exec.
func RegisterTracer ¶
Types ¶
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
func NewLifecycle ¶
type MockTransactional ¶
MockTransactional is an autogenerated mock type for the Transactional type
func NewMockTransactional ¶
func NewMockTransactional(t interface {
mock.TestingT
Cleanup(func())
}) *MockTransactional
NewMockTransactional creates a new instance of MockTransactional. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockTransactional) BeginTx ¶
func (_mock *MockTransactional) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
BeginTx provides a mock function for the type MockTransactional
func (*MockTransactional) EXPECT ¶
func (_m *MockTransactional) EXPECT() *MockTransactional_Expecter
type MockTransactional_BeginTx_Call ¶
MockTransactional_BeginTx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BeginTx'
func (*MockTransactional_BeginTx_Call) Return ¶
func (_c *MockTransactional_BeginTx_Call) Return(tx pgx.Tx, err error) *MockTransactional_BeginTx_Call
func (*MockTransactional_BeginTx_Call) Run ¶
func (_c *MockTransactional_BeginTx_Call) Run(run func(ctx context.Context, txOptions pgx.TxOptions)) *MockTransactional_BeginTx_Call
func (*MockTransactional_BeginTx_Call) RunAndReturn ¶
func (_c *MockTransactional_BeginTx_Call) RunAndReturn(run func(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)) *MockTransactional_BeginTx_Call
type MockTransactional_Expecter ¶
type MockTransactional_Expecter struct {
// contains filtered or unexported fields
}
func (*MockTransactional_Expecter) BeginTx ¶
func (_e *MockTransactional_Expecter) BeginTx(ctx interface{}, txOptions interface{}) *MockTransactional_BeginTx_Call
BeginTx is a helper method to define mock.On call
- ctx
- txOptions
type MockTx ¶
MockTx is an autogenerated mock type for the Tx type
func NewMockTx ¶
NewMockTx creates a new instance of MockTx. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockTx) CopyFrom ¶
func (_mock *MockTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
CopyFrom provides a mock function for the type MockTx
func (*MockTx) EXPECT ¶
func (_m *MockTx) EXPECT() *MockTx_Expecter
func (*MockTx) Exec ¶
func (_mock *MockTx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Exec provides a mock function for the type MockTx
func (*MockTx) LargeObjects ¶
func (_mock *MockTx) LargeObjects() pgx.LargeObjects
LargeObjects provides a mock function for the type MockTx
func (*MockTx) Prepare ¶
func (_mock *MockTx) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)
Prepare provides a mock function for the type MockTx
type MockTx_Begin_Call ¶
MockTx_Begin_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Begin'
func (*MockTx_Begin_Call) Return ¶
func (_c *MockTx_Begin_Call) Return(tx pgx.Tx, err error) *MockTx_Begin_Call
func (*MockTx_Begin_Call) Run ¶
func (_c *MockTx_Begin_Call) Run(run func(ctx context.Context)) *MockTx_Begin_Call
func (*MockTx_Begin_Call) RunAndReturn ¶
func (_c *MockTx_Begin_Call) RunAndReturn(run func(ctx context.Context) (pgx.Tx, error)) *MockTx_Begin_Call
type MockTx_Commit_Call ¶
MockTx_Commit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Commit'
func (*MockTx_Commit_Call) Return ¶
func (_c *MockTx_Commit_Call) Return(err error) *MockTx_Commit_Call
func (*MockTx_Commit_Call) Run ¶
func (_c *MockTx_Commit_Call) Run(run func(ctx context.Context)) *MockTx_Commit_Call
func (*MockTx_Commit_Call) RunAndReturn ¶
func (_c *MockTx_Commit_Call) RunAndReturn(run func(ctx context.Context) error) *MockTx_Commit_Call
type MockTx_Conn_Call ¶
MockTx_Conn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Conn'
func (*MockTx_Conn_Call) Return ¶
func (_c *MockTx_Conn_Call) Return(conn *pgx.Conn) *MockTx_Conn_Call
func (*MockTx_Conn_Call) Run ¶
func (_c *MockTx_Conn_Call) Run(run func()) *MockTx_Conn_Call
func (*MockTx_Conn_Call) RunAndReturn ¶
func (_c *MockTx_Conn_Call) RunAndReturn(run func() *pgx.Conn) *MockTx_Conn_Call
type MockTx_CopyFrom_Call ¶
MockTx_CopyFrom_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CopyFrom'
func (*MockTx_CopyFrom_Call) Return ¶
func (_c *MockTx_CopyFrom_Call) Return(n int64, err error) *MockTx_CopyFrom_Call
func (*MockTx_CopyFrom_Call) Run ¶
func (_c *MockTx_CopyFrom_Call) Run(run func(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource)) *MockTx_CopyFrom_Call
func (*MockTx_CopyFrom_Call) RunAndReturn ¶
func (_c *MockTx_CopyFrom_Call) RunAndReturn(run func(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)) *MockTx_CopyFrom_Call
type MockTx_Exec_Call ¶
MockTx_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'
func (*MockTx_Exec_Call) Return ¶
func (_c *MockTx_Exec_Call) Return(commandTag pgconn.CommandTag, err error) *MockTx_Exec_Call
func (*MockTx_Exec_Call) Run ¶
func (_c *MockTx_Exec_Call) Run(run func(ctx context.Context, sql string, arguments ...any)) *MockTx_Exec_Call
func (*MockTx_Exec_Call) RunAndReturn ¶
func (_c *MockTx_Exec_Call) RunAndReturn(run func(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)) *MockTx_Exec_Call
type MockTx_Expecter ¶
type MockTx_Expecter struct {
// contains filtered or unexported fields
}
func (*MockTx_Expecter) Begin ¶
func (_e *MockTx_Expecter) Begin(ctx interface{}) *MockTx_Begin_Call
Begin is a helper method to define mock.On call
- ctx
func (*MockTx_Expecter) Commit ¶
func (_e *MockTx_Expecter) Commit(ctx interface{}) *MockTx_Commit_Call
Commit is a helper method to define mock.On call
- ctx
func (*MockTx_Expecter) Conn ¶
func (_e *MockTx_Expecter) Conn() *MockTx_Conn_Call
Conn is a helper method to define mock.On call
func (*MockTx_Expecter) CopyFrom ¶
func (_e *MockTx_Expecter) CopyFrom(ctx interface{}, tableName interface{}, columnNames interface{}, rowSrc interface{}) *MockTx_CopyFrom_Call
CopyFrom is a helper method to define mock.On call
- ctx
- tableName
- columnNames
- rowSrc
func (*MockTx_Expecter) Exec ¶
func (_e *MockTx_Expecter) Exec(ctx interface{}, sql interface{}, arguments ...interface{}) *MockTx_Exec_Call
Exec is a helper method to define mock.On call
- ctx
- sql
- arguments
func (*MockTx_Expecter) LargeObjects ¶
func (_e *MockTx_Expecter) LargeObjects() *MockTx_LargeObjects_Call
LargeObjects is a helper method to define mock.On call
func (*MockTx_Expecter) Prepare ¶
func (_e *MockTx_Expecter) Prepare(ctx interface{}, name interface{}, sql interface{}) *MockTx_Prepare_Call
Prepare is a helper method to define mock.On call
- ctx
- name
- sql
func (*MockTx_Expecter) Query ¶
func (_e *MockTx_Expecter) Query(ctx interface{}, sql interface{}, args ...interface{}) *MockTx_Query_Call
Query is a helper method to define mock.On call
- ctx
- sql
- args
func (*MockTx_Expecter) QueryRow ¶
func (_e *MockTx_Expecter) QueryRow(ctx interface{}, sql interface{}, args ...interface{}) *MockTx_QueryRow_Call
QueryRow is a helper method to define mock.On call
- ctx
- sql
- args
func (*MockTx_Expecter) Rollback ¶
func (_e *MockTx_Expecter) Rollback(ctx interface{}) *MockTx_Rollback_Call
Rollback is a helper method to define mock.On call
- ctx
func (*MockTx_Expecter) SendBatch ¶
func (_e *MockTx_Expecter) SendBatch(ctx interface{}, b interface{}) *MockTx_SendBatch_Call
SendBatch is a helper method to define mock.On call
- ctx
- b
type MockTx_LargeObjects_Call ¶
MockTx_LargeObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LargeObjects'
func (*MockTx_LargeObjects_Call) Return ¶
func (_c *MockTx_LargeObjects_Call) Return(largeObjects pgx.LargeObjects) *MockTx_LargeObjects_Call
func (*MockTx_LargeObjects_Call) Run ¶
func (_c *MockTx_LargeObjects_Call) Run(run func()) *MockTx_LargeObjects_Call
func (*MockTx_LargeObjects_Call) RunAndReturn ¶
func (_c *MockTx_LargeObjects_Call) RunAndReturn(run func() pgx.LargeObjects) *MockTx_LargeObjects_Call
type MockTx_Prepare_Call ¶
MockTx_Prepare_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Prepare'
func (*MockTx_Prepare_Call) Return ¶
func (_c *MockTx_Prepare_Call) Return(statementDescription *pgconn.StatementDescription, err error) *MockTx_Prepare_Call
func (*MockTx_Prepare_Call) Run ¶
func (_c *MockTx_Prepare_Call) Run(run func(ctx context.Context, name string, sql string)) *MockTx_Prepare_Call
func (*MockTx_Prepare_Call) RunAndReturn ¶
func (_c *MockTx_Prepare_Call) RunAndReturn(run func(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)) *MockTx_Prepare_Call
type MockTx_QueryRow_Call ¶
MockTx_QueryRow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryRow'
func (*MockTx_QueryRow_Call) Return ¶
func (_c *MockTx_QueryRow_Call) Return(row pgx.Row) *MockTx_QueryRow_Call
func (*MockTx_QueryRow_Call) Run ¶
func (_c *MockTx_QueryRow_Call) Run(run func(ctx context.Context, sql string, args ...any)) *MockTx_QueryRow_Call
func (*MockTx_QueryRow_Call) RunAndReturn ¶
func (_c *MockTx_QueryRow_Call) RunAndReturn(run func(ctx context.Context, sql string, args ...any) pgx.Row) *MockTx_QueryRow_Call
type MockTx_Query_Call ¶
MockTx_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query'
func (*MockTx_Query_Call) Return ¶
func (_c *MockTx_Query_Call) Return(rows pgx.Rows, err error) *MockTx_Query_Call
func (*MockTx_Query_Call) Run ¶
func (_c *MockTx_Query_Call) Run(run func(ctx context.Context, sql string, args ...any)) *MockTx_Query_Call
func (*MockTx_Query_Call) RunAndReturn ¶
func (_c *MockTx_Query_Call) RunAndReturn(run func(ctx context.Context, sql string, args ...any) (pgx.Rows, error)) *MockTx_Query_Call
type MockTx_Rollback_Call ¶
MockTx_Rollback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rollback'
func (*MockTx_Rollback_Call) Return ¶
func (_c *MockTx_Rollback_Call) Return(err error) *MockTx_Rollback_Call
func (*MockTx_Rollback_Call) Run ¶
func (_c *MockTx_Rollback_Call) Run(run func(ctx context.Context)) *MockTx_Rollback_Call
func (*MockTx_Rollback_Call) RunAndReturn ¶
func (_c *MockTx_Rollback_Call) RunAndReturn(run func(ctx context.Context) error) *MockTx_Rollback_Call
type MockTx_SendBatch_Call ¶
MockTx_SendBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendBatch'
func (*MockTx_SendBatch_Call) Return ¶
func (_c *MockTx_SendBatch_Call) Return(batchResults pgx.BatchResults) *MockTx_SendBatch_Call
func (*MockTx_SendBatch_Call) Run ¶
func (_c *MockTx_SendBatch_Call) Run(run func(ctx context.Context, b *pgx.Batch)) *MockTx_SendBatch_Call
func (*MockTx_SendBatch_Call) RunAndReturn ¶
func (_c *MockTx_SendBatch_Call) RunAndReturn(run func(ctx context.Context, b *pgx.Batch) pgx.BatchResults) *MockTx_SendBatch_Call
type Tracer ¶
type Tracer struct {
pgx.QueryTracer
pgx.BatchTracer
pgx.CopyFromTracer
pgx.PrepareTracer
pgx.ConnectTracer
}
func (*Tracer) Apply ¶
func (s *Tracer) Apply(connConfig *pgx.ConnConfig)
type Transactional ¶
type TxManager ¶
type TxManager interface {
// Do run tx with base pgx options
Do(ctx context.Context, exec TxFunc) error
// DoWithOptions run tx with users options
DoWithOptions(ctx context.Context, opt pgx.TxOptions, exec TxFunc) error
}
TxManager tx wrapper interface
func NewTxManager ¶
NewTxManager TxManager constructor