xpgx

package
v0.0.0-...-c6a8645 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDSNKey = "PG_DSN"
	DefaultDSN    = `postgres://postgres:postgres@localhost:5432/postgres`
)

Variables

This section is empty.

Functions

func NewModule

func NewModule(poolName string) fx.Option

func NewPool

func NewPool(cfg *pgxpool.Config) (*pgxpool.Pool, error)

NewPool создаёт новый пул соединений с базой данных

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 RegisterLifecycle

func RegisterLifecycle(lc fx.Lifecycle, plc *Lifecycle)

RegisterLifecycle

func RegisterTracer

func RegisterTracer(tr *Tracer, cfg *pgxpool.Config)

Types

type Lifecycle

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

func NewLifecycle

func NewLifecycle(pool *pgxpool.Pool) *Lifecycle

func (*Lifecycle) OnStart

func (s *Lifecycle) OnStart(ctx context.Context) error

onStart проверяет соединение при запуске приложения

func (*Lifecycle) OnStop

func (s *Lifecycle) OnStop(ctx context.Context) error

OnStop closes connection pool correctly

func (*Lifecycle) Register

func (s *Lifecycle) Register(lc fx.Lifecycle)

type MockTransactional

type MockTransactional struct {
	mock.Mock
}

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

type MockTransactional_BeginTx_Call

type MockTransactional_BeginTx_Call struct {
	*mock.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 (*MockTransactional_BeginTx_Call) Run

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

type MockTx struct {
	mock.Mock
}

MockTx is an autogenerated mock type for the Tx type

func NewMockTx

func NewMockTx(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockTx

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) Begin

func (_mock *MockTx) Begin(ctx context.Context) (pgx.Tx, error)

Begin provides a mock function for the type MockTx

func (*MockTx) Commit

func (_mock *MockTx) Commit(ctx context.Context) error

Commit provides a mock function for the type MockTx

func (*MockTx) Conn

func (_mock *MockTx) Conn() *pgx.Conn

Conn provides a mock function for the type MockTx

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

func (*MockTx) Query

func (_mock *MockTx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

Query provides a mock function for the type MockTx

func (*MockTx) QueryRow

func (_mock *MockTx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

QueryRow provides a mock function for the type MockTx

func (*MockTx) Rollback

func (_mock *MockTx) Rollback(ctx context.Context) error

Rollback provides a mock function for the type MockTx

func (*MockTx) SendBatch

func (_mock *MockTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

SendBatch provides a mock function for the type MockTx

type MockTx_Begin_Call

type MockTx_Begin_Call struct {
	*mock.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

type MockTx_Commit_Call struct {
	*mock.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

type MockTx_Conn_Call struct {
	*mock.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

type MockTx_CopyFrom_Call struct {
	*mock.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 (*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

type MockTx_Exec_Call struct {
	*mock.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

type MockTx_LargeObjects_Call struct {
	*mock.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 (*MockTx_LargeObjects_Call) Run

func (*MockTx_LargeObjects_Call) RunAndReturn

func (_c *MockTx_LargeObjects_Call) RunAndReturn(run func() pgx.LargeObjects) *MockTx_LargeObjects_Call

type MockTx_Prepare_Call

type MockTx_Prepare_Call struct {
	*mock.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

type MockTx_QueryRow_Call struct {
	*mock.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 (*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

type MockTx_Query_Call struct {
	*mock.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

type MockTx_Rollback_Call struct {
	*mock.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 (*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

type MockTx_SendBatch_Call struct {
	*mock.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 (*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

func NewTracer

func NewTracer() *Tracer

func (*Tracer) Apply

func (s *Tracer) Apply(connConfig *pgx.ConnConfig)

type Transactional

type Transactional interface {
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
}

type TxFunc

type TxFunc func(tx pgx.Tx) error

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

func NewTxManager(pool *pgxpool.Pool) TxManager

NewTxManager TxManager constructor

Jump to

Keyboard shortcuts

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