Documentation
¶
Overview ¶
Package stdpgxtxfx provides database transactors.
Index ¶
- Variables
- func BHJTx[C bhttp.Context, I, O any](txr *stdtx.Transactor[pgx.Tx], ...) bhttp.HandlerFunc[C]
- func CTx[I, O any](ctx context.Context, txr *stdtx.Transactor[pgx.Tx], req *connect.Request[I], ...) (*connect.Response[O], error)
- func HJTx[I, O any](ctx context.Context, txr *stdtx.Transactor[pgx.Tx], resp http.ResponseWriter, ...) error
- func Provide(applicationName string) fx.Option
- func TestProvide(applicationName, endRoleUsername, endRolePassword string) fx.Option
- type Config
- type Params
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var PgErrorsToConnectError = map[string]func(lpgErr *pgconn.PgError, logs *zap.Logger) error{ "42501": func(pgErr *pgconn.PgError, logs *zap.Logger) error { logs.Info("database permission denied", zap.Error(pgErr)) return connect.NewError(connect.CodePermissionDenied, errors.New("database permission denied")) }, }
PgErrorsToConnectError statically defines how database errors are mapped to connect errors.
Functions ¶
func BHJTx ¶ added in v0.0.146
func BHJTx[C bhttp.Context, I, O any]( txr *stdtx.Transactor[pgx.Tx], fn func(context.Context, *zap.Logger, pgx.Tx, *I) (*O, error), ) bhttp.HandlerFunc[C]
BHJTx creates an bhttp handler that transacts on json request and response.
func CTx ¶ added in v0.0.144
func CTx[I, O any]( ctx context.Context, txr *stdtx.Transactor[pgx.Tx], req *connect.Request[I], fn func(context.Context, *zap.Logger, pgx.Tx, *I) (*O, error), ) (*connect.Response[O], error)
CTx transacts while returning a protobuf message for the response. It is a shorthant for the most common scenario in our connect RPC code and makes it way more succinct.
func HJTx ¶ added in v0.0.145
func HJTx[I, O any]( ctx context.Context, txr *stdtx.Transactor[pgx.Tx], resp http.ResponseWriter, req *http.Request, fn func(context.Context, *zap.Logger, pgx.Tx, *I) (*O, error), ) error
HJTx transacts while encoding and decoding a buffered JSON HTTP request/response.
func TestProvide ¶
TestProvide provides project-specific transactor config to make it easy for any test package to interact with the database.
Types ¶
type Config ¶
type Config struct {
TestMaxQueryCosts float64 `env:"TEST_MAX_QUERY_COSTS"`
}
Config configures the transact components.
Click to show internal directories.
Click to hide internal directories.