Documentation
¶
Overview ¶
Package stdent provides re-usable code for using Ent.
Index ¶
- func AttemptFromContext(ctx context.Context) int
- func ContextWithAttempts(ctx context.Context, v int) context.Context
- func ContextWithTx[T Tx](ctx context.Context, tx T) context.Context
- func Transact0[T Tx](ctx context.Context, txr *Transactor[T], ...) (err error)
- func Transact1[T Tx, U any](ctx context.Context, txr *Transactor[T], ...) (res U, err error)
- func TxFromContext[T Tx](ctx context.Context) T
- type Client
- type Option
- type Transactor
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttemptFromContext ¶ added in v0.0.50
AttemptFromContext returns which execution attempt it is. Panics if this information is not present.
func ContextWithAttempts ¶ added in v0.0.50
ContextWithAttempts stores which execution attempt it is.
func ContextWithTx ¶ added in v0.0.50
ContextWithTx returns a context with the Tx in it.
func Transact0 ¶ added in v0.0.50
func Transact0[T Tx]( ctx context.Context, txr *Transactor[T], fnc func(ctx context.Context, tx T) error, ) (err error)
Transact0 runs Transact1 but without a value to return.
func Transact1 ¶ added in v0.0.50
func Transact1[T Tx, U any]( ctx context.Context, txr *Transactor[T], fnc func(ctx context.Context, tx T) (U, error), ) (res U, err error)
Transact1 runs fnc in a transaction T derived from the provided Ent client while returning one value of type U. The implementation is taken from the official docs: https://entgo.io/docs/transactions#best-practices. If the context already has a transaction, it runs it in that one.
func TxFromContext ¶ added in v0.0.50
TxFromContext will get a transaction of type T from the context or panic.
Types ¶
type Option ¶ added in v0.0.50
type Option func(opts *options)
func IsolationLevel ¶ added in v0.0.50
func IsolationLevel(v sql.IsolationLevel) Option
IsolationLevel specifies the isolation level for new transactions.
func SerializationFailureCodes ¶ added in v0.0.50
SerializationFailureCodes configures which PostgreSQL error codes should be considered serialization failures.
func SerializationFailureMaxRetries ¶ added in v0.0.50
SerializationFailureMaxRetries configures the maximum number of retries in case the transacted code encounters a serialization failure.
type Transactor ¶ added in v0.0.50
type Transactor[T Tx] struct { // contains filtered or unexported fields }
Directories
¶
Path | Synopsis |
---|---|
Package stdenttest is a utility for writing tests on ent transaction.
|
Package stdenttest is a utility for writing tests on ent transaction. |