stdpgxtxconnect

package
v0.0.260 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stdpgxtxconnect runs connect-go v2 RPCs in a transaction from the transactors that [stdpgxtxfx] provides. It is the v2 counterpart of [stdpgxtxfx.CTx], which takes connect-go v1 requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CTx

func CTx[I, O any](
	ctx context.Context,
	txr *stdtx.Transactor[pgx.Tx],
	req *I,
	fn func(context.Context, *zap.Logger, pgx.Tx, *I) (*O, error),
	mappers ...stdcrpcintercept.ErrorMapper,
) (*O, error)

CTx runs fn in a transaction from txr and returns its response message. It is a shorthand for the most common scenario in our connect RPC code. The transaction commits when fn returns no error and rolls back otherwise. stdtx retries fn when the transaction fails to serialize, so fn must be safe to run more than once. The context must carry a logger, see stdctx.WithLogger.

CTx maps the error of the transaction with the first rule that applies:

  • a *connect.Error that fn returns is returned as is, so it reaches the client;
  • each of mappers in turn, until one returns an error, as stdcrpcintercept.NewServerErrors runs them; pass them to map the errors of this RPC only, such as a unique violation to the ALREADY_EXISTS of the resource it creates, and to the server interceptor for errors that recur across RPCs;
  • a serialization failure or deadlock (SQLSTATE 40001 or 40P01) that remains after stdtx ran out of retries becomes ABORTED, the code for a concurrency conflict that the client may retry;
  • other errors are returned as stdtx returns them, for the server's error interceptor to map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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