Documentation
¶
Overview ¶
Package atomic contains interfaces and shared code for the individual driver implementations to achieve transaction like behavior on access of remote systems in an implementation agnostic manner in business layers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultBackoffs = []time.Duration{ 100 * time.Millisecond, time.Second, 5 * time.Second, 10 * time.Second, 30 * time.Second, 1 * time.Minute, 5 * time.Minute, }
DefaultBackoffs are the default backoffs for transacters
Functions ¶
func DefaultRetry ¶
DefaultRetry is the default retry function for transacters. It retries errors that are have one of the following errors in their chain: - context.DeadlineExceeded - net.ErrClosed - os.ErrDeadlineExceeded It retries for a maximum of len(backoffs) times.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is the type of the context keys used by the transacter.
const ( // SessionContextKey is the key used to store active transacter sessions in context. SessionContextKey ContextKey = "session" )
type Transacter ¶
type Transacter[Resources any] interface { // Transact executes run atomically, rolling back on error and committing on return. // Atomicity (depending on implementation in the remote systems accessed) can only be guaranteed // for statements made on the fields of the provided Resources type. // Transact opens a new session before calling run and inserts it into the context. // If a Transact session is already present in the provided context Transact will reuse that // session. // Depending on the implementation of Transact it is possible that this leads to nested // transactions. // In this case on error in the inner call to Transact only the statements made in the inner run // functions are rollbacked. // For this to work it is necessary to always pass the use the context provided to run as the // parent context in statements inside the run function. Transact(ctx context.Context, run func(context.Context, Resources) error) error }
Transacter interface consists of the Transact method.
Directories
¶
Path | Synopsis |
---|---|
Package example provides a minimal example implementation of how to use the generic transacter.
|
Package example provides a minimal example implementation of how to use the generic transacter. |
Package generic implements a generic Transacter which is compatible with a wide range of executors for different data sources.
|
Package generic implements a generic Transacter which is compatible with a wide range of executors for different data sources. |
crdb
Package crdb implements [generic.Executer] for cockroachdb
|
Package crdb implements [generic.Executer] for cockroachdb |
gorm
Package gorm provides a way to integrate multiple different versions of gorm / potentially other databases go-atomic if they implement the GormlikeDB interface.
|
Package gorm provides a way to integrate multiple different versions of gorm / potentially other databases go-atomic if they implement the GormlikeDB interface. |
sql
Package sql implements [generic.Executer] for the stdlib sql db
|
Package sql implements [generic.Executer] for the stdlib sql db |
sqlx
Package sqlx implements [generic.Executer] for the sqlx databases
|
Package sqlx implements [generic.Executer] for the sqlx databases |
Click to show internal directories.
Click to hide internal directories.