Documentation ¶
Index ¶
- func ExtractRow[T any](row Row, callback func(row Row) T) (t T)
- func ExtractRowSet[T any](rowSet RowSet, callback func(rowSet RowSet) []T) []T
- func FromContext[T *TransactionContext](ctx context.Context) T
- func Register(name string, driver driver.Driver)
- type Connection
- type DataSource
- type DataSourceTransactionManager
- type DefaultTransactionStatus
- type IsolationLevel
- type PreparedStatement
- func (p *PreparedStatement) Close() error
- func (p *PreparedStatement) ExecContext(ctx context.Context, args ...any) (Result, error)
- func (p *PreparedStatement) QueryContext(ctx context.Context, args ...any) (RowSet, error)
- func (p *PreparedStatement) QueryRowContext(ctx context.Context, args ...any) (Row, error)
- type Propagation
- type Result
- type Row
- type RowSet
- type Statement
- type TransactionCallback
- type TransactionContext
- type TransactionManager
- type TransactionOption
- type TransactionOptions
- func (o *TransactionOptions) IsReadOnly() bool
- func (o *TransactionOptions) IsolationLevel() IsolationLevel
- func (o *TransactionOptions) Merge(options *TransactionOptions) *TransactionOptions
- func (o *TransactionOptions) Override(options ...TransactionOption) *TransactionOptions
- func (o *TransactionOptions) Propagation() Propagation
- func (o *TransactionOptions) Timeout() time.Duration
- type TransactionStatus
- type TransactionTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractRow ¶
func ExtractRowSet ¶
func FromContext ¶
func FromContext[T *TransactionContext](ctx context.Context) T
Types ¶
type Connection ¶
type Connection interface { ExecContext(ctx context.Context, query string, args ...any) (Result, error) PrepareContext(ctx context.Context, query string, args ...any) (Statement, error) QueryContext(ctx context.Context, query string, args ...any) (RowSet, error) QueryRowContext(ctx context.Context, query string, args ...any) (Row, error) PingContext(ctx context.Context) error SetConnMaxLifetime(d time.Duration) error SetConnMaxIdleTime(d time.Duration) error SetMaxIdleConns(n int) error SetMaxOpenConns(n int) error BeginTransaction(ctx context.Context) (TransactionStatus, error) Driver() driver.Driver Close() error IsClosed() bool }
type DataSource ¶
type DataSource interface {
GetConnection() (Connection, error)
}
type DataSourceTransactionManager ¶
type DataSourceTransactionManager struct {
// contains filtered or unexported fields
}
func NewDataSourceTransactionManager ¶
func NewDataSourceTransactionManager(dataSource DataSource) *DataSourceTransactionManager
func (*DataSourceTransactionManager) Commit ¶
func (m *DataSourceTransactionManager) Commit() error
func (*DataSourceTransactionManager) GetTransaction ¶
func (m *DataSourceTransactionManager) GetTransaction(ctx context.Context, options ...any) (TransactionStatus, error)
func (*DataSourceTransactionManager) Rollback ¶
func (m *DataSourceTransactionManager) Rollback() error
type DefaultTransactionStatus ¶
type DefaultTransactionStatus struct { }
func NewDefaultTransactionStatus ¶
func NewDefaultTransactionStatus() *DefaultTransactionStatus
type IsolationLevel ¶
type IsolationLevel int
const ( LevelDefault IsolationLevel = iota LevelReadUncommitted LevelReadCommitted LevelWriteCommitted LevelRepeatableRead LevelSnapshot LevelSerializable LevelLinearizable )
type PreparedStatement ¶
type PreparedStatement struct {
// contains filtered or unexported fields
}
func NewPreparedStatement ¶
func NewPreparedStatement(stmt *sql.Stmt) *PreparedStatement
func (*PreparedStatement) Close ¶
func (p *PreparedStatement) Close() error
func (*PreparedStatement) ExecContext ¶
func (*PreparedStatement) QueryContext ¶
func (*PreparedStatement) QueryRowContext ¶
type Propagation ¶
type Propagation int
const ( PropagationRequired Propagation = iota PropagationSupports PropagationMandatory PropagationNever PropagationNotSupported PropagationNested PropagationRequiredNew )
type TransactionContext ¶
type TransactionContext struct { }
type TransactionManager ¶
type TransactionOption ¶
type TransactionOption func(options *TransactionOptions)
func WithIsolation ¶
func WithIsolation(isolationLevel IsolationLevel) TransactionOption
func WithPropagation ¶
func WithPropagation(propagation Propagation) TransactionOption
func WithReadOnly ¶
func WithReadOnly(readOnly bool) TransactionOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) TransactionOption
type TransactionOptions ¶
type TransactionOptions struct {
// contains filtered or unexported fields
}
func DefaultTransactionOptions ¶
func DefaultTransactionOptions() *TransactionOptions
func NewTransactionOptions ¶
func NewTransactionOptions(opts ...TransactionOption) *TransactionOptions
func (*TransactionOptions) IsReadOnly ¶
func (o *TransactionOptions) IsReadOnly() bool
func (*TransactionOptions) IsolationLevel ¶
func (o *TransactionOptions) IsolationLevel() IsolationLevel
func (*TransactionOptions) Merge ¶
func (o *TransactionOptions) Merge(options *TransactionOptions) *TransactionOptions
func (*TransactionOptions) Override ¶
func (o *TransactionOptions) Override(options ...TransactionOption) *TransactionOptions
func (*TransactionOptions) Propagation ¶
func (o *TransactionOptions) Propagation() Propagation
func (*TransactionOptions) Timeout ¶
func (o *TransactionOptions) Timeout() time.Duration
type TransactionStatus ¶
type TransactionTemplate ¶
type TransactionTemplate struct {
// contains filtered or unexported fields
}
func NewTransactionTemplate ¶
func NewTransactionTemplate(manager TransactionManager) *TransactionTemplate
func (*TransactionTemplate) Execute ¶
func (t *TransactionTemplate) Execute(ctx context.Context, callback TransactionCallback) (result any, err error)
Click to show internal directories.
Click to hide internal directories.