Documentation
¶
Index ¶
- func Func(ctx context.Context, logger *slog.Logger, provider Provider, ...) error
- func Value[T any](ctx context.Context, logger *slog.Logger, provider Provider, ...) (T, error)
- func Values[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 Func ¶
func Func( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) error, ) error
Func executes the given function within a transaction, automatically committing or rolling back the transaction as necessary.
func Value ¶
func Value[T any]( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) (T, error), ) (T, error)
Value 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 Values ¶
func Values[T1, T2 any]( ctx context.Context, logger *slog.Logger, provider Provider, fn func(Datastore) (T1, T2, error), ) (T1, T2, error)
Values 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.