Documentation
¶
Index ¶
- func GetConnStr(opts PgxpoolOptions) string
- func NewPgxTracer() pgx.QueryTracer
- func NewPgxpool(opts PgxpoolOptions) (*pgxpool.Pool, error)
- type DBRouter
- func (c *DBRouter) Begin(ctx context.Context) (pgx.Tx, error)
- func (c *DBRouter) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (c *DBRouter) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
- func (c *DBRouter) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (c *DBRouter) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- type DBTX
- type PgxpoolOptions
- type QueryLogger
- type TraceData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConnStr ¶
func GetConnStr(opts PgxpoolOptions) string
func NewPgxTracer ¶
func NewPgxTracer() pgx.QueryTracer
func NewPgxpool ¶
func NewPgxpool(opts PgxpoolOptions) (*pgxpool.Pool, error)
Types ¶
type DBRouter ¶
type DBRouter struct {
// contains filtered or unexported fields
}
DBRouter wrapper that routes queries to appropriate pools based on operation type
func NewDBRouter ¶
NewDBRouter creates a new DBRouter database wrapper
func (*DBRouter) Begin ¶
Begin starts a transaction Transactions can contain both read and write operations, so we use the write pool to ensure consistency and avoid potential issues with read replicas
func (*DBRouter) CopyFrom ¶
func (c *DBRouter) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
CopyFrom uses COPY protocol to insert multiple rows This is always a write operation, so it uses the write pool
func (*DBRouter) Exec ¶
func (c *DBRouter) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
Exec executes a query without returning any rows
type DBTX ¶
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
Begin(context.Context) (pgx.Tx, error)
}
type PgxpoolOptions ¶
type QueryLogger ¶
type QueryLogger struct{}
func (*QueryLogger) TraceQueryEnd ¶
func (ql *QueryLogger) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
func (*QueryLogger) TraceQueryStart ¶
func (ql *QueryLogger) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
Click to show internal directories.
Click to hide internal directories.