Documentation
¶
Index ¶
- func TxFunc(ctx context.Context, logger *slog.Logger, provider Provider, ...) error
- func TxValue[T any](ctx context.Context, logger *slog.Logger, provider Provider, ...) (T, error)
- func TxValues[T1, T2 any](ctx context.Context, logger *slog.Logger, provider Provider, ...) (T1, T2, error)
- type CommitFn
- type Datastore
- type Provider
- type RollbackFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TxFunc ¶
func TxFunc( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) error, ) error
TxFunc executes the given function within a transaction, automatically committing or rolling back the transaction as necessary.
func TxValue ¶
func TxValue[T any]( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) (T, error), ) (T, error)
TxValue executes the given function within a transaction, automatically committing or rolling back the transaction as necessary. It returns the non-error value returned by fn on success.
func TxValues ¶
func TxValues[T1, T2 any]( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) (T1, T2, error), ) (T1, T2, error)
TxValues executes the given function within a transaction, automatically committing or rolling back the transaction as necessary. It returns the non-error values returned by fn on success.
Types ¶
type Datastore ¶
type Datastore interface {
repositories.AuditEvent
repositories.Resource
}
Datastore is a unified interface for repositories.
type Provider ¶
type Provider interface {
Datastore() Datastore
BeginTx(context.Context) (Datastore, CommitFn, RollbackFn, error)
}
Provider provides access to either a transactional or non-transactional database.
type RollbackFn ¶
type RollbackFn func() error
RollbackFn rolls back a transaction. No error should be produced for a committed transaction.