Documentation
¶
Index ¶
- func Run[R any](ctx context.Context, creator Creator, cb func(ctx context.Context) (R, error)) (R, error)
- func RunInNewTransaction[R any](ctx context.Context, creator Creator, cb func(ctx context.Context) (R, error)) (R, error)
- func RunWithNoValue(ctx context.Context, creator Creator, cb func(ctx context.Context) error) error
- func SetDriverOnContext(ctx context.Context, tx Driver) (context.Context, error)
- type Creator
- type Driver
- type DriverConflictError
- type DriverNotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run[R any](ctx context.Context, creator Creator, cb func(ctx context.Context) (R, error)) (R, error)
Runs the callback inside a transaction
func RunInNewTransaction ¶
func RunInNewTransaction[R any](ctx context.Context, creator Creator, cb func(ctx context.Context) (R, error)) (R, error)
RunInNewTransaction starts and commits a transaction independently of any transaction in ctx. For Ent-backed adapters, it acquires a separate database connection and shadows the caller's transaction in the callback.
WARNING: The callback's writes are not atomic with the caller. They remain committed if the caller later rolls back, and the callback cannot observe the caller's uncommitted writes. Calling this while the caller holds locks needed by the callback can deadlock. Concurrent use can also exhaust the connection pool because an operation may hold one connection while acquiring another.
Use only when the domain explicitly requires a durable side effect outside the caller's transaction and the visibility, locking, and connection-pool risks have been reviewed.
func RunWithNoValue ¶
RunWithNoValue the callback inside a transaction with no return value
Types ¶
type DriverConflictError ¶
type DriverConflictError struct{}
func (*DriverConflictError) Error ¶
func (e *DriverConflictError) Error() string
type DriverNotFoundError ¶
type DriverNotFoundError struct{}
func (*DriverNotFoundError) Error ¶
func (e *DriverNotFoundError) Error() string