Documentation ¶
Index ¶
- func BulkLoad(ctx context.Context, tx pgx.Tx, tupleTableName string, colNames []string, ...) (uint64, error)
- func ConfigureOTELTracer(connConfig *pgx.ConnConfig)
- func ConfigurePGXLogger(connConfig *pgx.ConnConfig)
- func ConnectWithInstrumentation(ctx context.Context, url string) (*pgx.Conn, error)
- func ConvertToWriteConstraintError(livingTupleConstraints []string, err error) error
- func IsCancellationError(err error) bool
- func IsSerializationError(err error) bool
- func NewPGXExecutor(querier DBFuncQuerier) common.ExecuteQueryFunc
- func ParseConfigWithInstrumentation(url string) (*pgx.ConnConfig, error)
- func SleepOnErr(ctx context.Context, err error, retries uint8)
- type ComposedTracer
- type ConnPooler
- type DBFuncQuerier
- type InterceptorPooler
- func (i InterceptorPooler) Begin(ctx context.Context) (pgx.Tx, error)
- func (i InterceptorPooler) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (i InterceptorPooler) Close()
- func (i InterceptorPooler) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (i InterceptorPooler) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
- func (i InterceptorPooler) Query(ctx context.Context, sql string, optionsAndArgs ...any) (pgx.Rows, error)
- func (i InterceptorPooler) QueryRow(ctx context.Context, sql string, optionsAndArgs ...any) pgx.Row
- type PoolOptions
- type Querier
- type QuerierFuncs
- func (t *QuerierFuncs) ExecFunc(ctx context.Context, ...) error
- func (t *QuerierFuncs) QueryFunc(ctx context.Context, rowsFunc func(ctx context.Context, rows pgx.Rows) error, ...) error
- func (t *QuerierFuncs) QueryRowFunc(ctx context.Context, rowFunc func(ctx context.Context, row pgx.Row) error, ...) error
- type QueryInterceptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureOTELTracer ¶ added in v1.24.0
func ConfigureOTELTracer(connConfig *pgx.ConnConfig)
ConfigureOTELTracer adds OTEL tracing to a pgx.ConnConfig
func ConfigurePGXLogger ¶
func ConfigurePGXLogger(connConfig *pgx.ConnConfig)
ConfigurePGXLogger sets zerolog global logger into the connection pool configuration, and maps info level events to debug, as they are rather verbose for SpiceDB's info level
func ConnectWithInstrumentation ¶ added in v1.29.0
ConnectWithInstrumentation returns a pgx.Conn that has been instrumented for observability
func ConvertToWriteConstraintError ¶
ConvertToWriteConstraintError converts the given Postgres error into a CreateRelationshipExistsError if applicable. If not applicable, returns nils.
func IsCancellationError ¶ added in v1.26.0
IsCancellationError determines if an error returned by pgx has been caused by context cancellation.
func IsSerializationError ¶ added in v1.26.0
func NewPGXExecutor ¶
func NewPGXExecutor(querier DBFuncQuerier) common.ExecuteQueryFunc
NewPGXExecutor creates an executor that uses the pgx library to make the specified queries.
func ParseConfigWithInstrumentation ¶ added in v1.29.0
ParseConfigWithInstrumentation returns a pgx.ConnConfig that has been instrumented for observability
Types ¶
type ComposedTracer ¶ added in v1.24.0
type ComposedTracer struct {
Tracers []pgx.QueryTracer
}
ComposedTracer allows adding multiple tracers to a pgx.ConnConfig
func (*ComposedTracer) TraceQueryEnd ¶ added in v1.24.0
func (m *ComposedTracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
func (*ComposedTracer) TraceQueryStart ¶ added in v1.24.0
func (m *ComposedTracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
type ConnPooler ¶ added in v1.18.1
type ConnPooler interface { Querier Begin(ctx context.Context) (pgx.Tx, error) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) Close() }
ConnPooler is an interface to pgx.Pool methods used by postgres-based datastores
func MustNewInterceptorPooler ¶ added in v1.18.1
func MustNewInterceptorPooler(pooler ConnPooler, interceptor QueryInterceptor) ConnPooler
type DBFuncQuerier ¶ added in v1.22.0
type DBFuncQuerier interface { ExecFunc(ctx context.Context, tagFunc func(ctx context.Context, tag pgconn.CommandTag, err error) error, sql string, arguments ...any) error QueryFunc(ctx context.Context, rowsFunc func(ctx context.Context, rows pgx.Rows) error, sql string, optionsAndArgs ...any) error QueryRowFunc(ctx context.Context, rowFunc func(ctx context.Context, row pgx.Row) error, sql string, optionsAndArgs ...any) error }
DBFuncQuerier is satisfied by RetryPool and QuerierFuncs (which can wrap a pgxpool or transaction)
func QuerierFuncsFor ¶ added in v1.22.0
func QuerierFuncsFor(d Querier) DBFuncQuerier
type InterceptorPooler ¶ added in v1.18.1
type InterceptorPooler struct {
// contains filtered or unexported fields
}
func (InterceptorPooler) Begin ¶ added in v1.18.1
func (i InterceptorPooler) Begin(ctx context.Context) (pgx.Tx, error)
func (InterceptorPooler) BeginTx ¶ added in v1.18.1
func (i InterceptorPooler) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
func (InterceptorPooler) Close ¶ added in v1.18.1
func (i InterceptorPooler) Close()
func (InterceptorPooler) Exec ¶ added in v1.18.1
func (i InterceptorPooler) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
type PoolOptions ¶ added in v1.18.0
type PoolOptions struct { ConnMaxIdleTime *time.Duration ConnMaxLifetime *time.Duration ConnMaxLifetimeJitter *time.Duration ConnHealthCheckInterval *time.Duration MinOpenConns *int MaxOpenConns *int }
PoolOptions is the set of configuration used for a pgx connection pool.
func (PoolOptions) ConfigurePgx ¶ added in v1.18.0
func (opts PoolOptions) ConfigurePgx(pgxConfig *pgxpool.Config)
ConfigurePgx applies PoolOptions to a pgx connection pool confiugration.
type Querier ¶ added in v1.19.0
type Querier interface { Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, optionsAndArgs ...any) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, optionsAndArgs ...any) pgx.Row }
Querier holds common methods for connections and pools, equivalent to Querier (which is deprecated for pgx v5)
type QuerierFuncs ¶ added in v1.22.0
type QuerierFuncs struct {
// contains filtered or unexported fields
}
type QueryInterceptor ¶ added in v1.18.1
type QueryInterceptor interface { // InterceptExec is the method to intercept Querier.Exec. The implementation is responsible to invoke the // delegate with the provided arguments InterceptExec(ctx context.Context, delegate Querier, sql string, arguments ...any) (pgconn.CommandTag, error) // InterceptQuery is the method to intercept Querier.Query. The implementation is responsible to invoke the // delegate with the provided arguments InterceptQuery(ctx context.Context, delegate Querier, sql string, args ...any) (pgx.Rows, error) // InterceptQueryRow is the method to intercept Querier.QueryRow. The implementation is responsible to invoke the // delegate with the provided arguments InterceptQueryRow(ctx context.Context, delegate Querier, sql string, optionsAndArgs ...any) pgx.Row }
QueryInterceptor exposes a mechanism to intercept all methods exposed in Querier This can be used as a sort of middleware layer for pgx queries