Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCommitError ¶
IsCommitError checks if an error is a CommitError.
func NewCommitError ¶
NewCommitError creates an error that will commit the transaction but still return an error.
Types ¶
type CommitError ¶
type CommitError struct {
Err error
}
CommitError wraps an error that should still allow transaction to commit.
func (*CommitError) Error ¶
func (e *CommitError) Error() string
func (*CommitError) Unwrap ¶
func (e *CommitError) Unwrap() error
type Config ¶
type Config struct {
Host string
Port int
Database string
Username string
Password string
Schema string
}
Config holds database configuration
type PoolConfig ¶
type PoolConfig struct {
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
PoolConfig holds connection pool settings
type TransactionManager ¶
type TransactionManager interface {
WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error
}
TransactionManager defines the interface for transaction management.
type TxManager ¶
type TxManager struct {
// contains filtered or unexported fields
}
func NewTxManager ¶
func (*TxManager) WithTransaction ¶
WithTransaction runs fn within a transaction. If fn returns nil, the transaction is committed. If fn returns a CommitError, the transaction is committed but the error is returned. If fn returns any other error, the transaction is rolled back.
Click to show internal directories.
Click to hide internal directories.