transaction

package
v1.0.0-beta.186 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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 SetDriverOnContext

func SetDriverOnContext(ctx context.Context, tx Driver) (context.Context, error)

Types

type Creator

type Creator interface {
	Tx(ctx context.Context) (context.Context, Driver, error)
}

Able to start a new transaction

type Driver

type Driver interface {
	Commit() error
	Rollback() error
	SavePoint() error
}

Driver is an interface for transaction drivers

func GetDriverFromContext

func GetDriverFromContext(ctx context.Context) (Driver, error)

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

Jump to

Keyboard shortcuts

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