Documentation
¶
Index ¶
- Constants
- func CleanCommonHook()
- func RegisterATExecutor(dt types.DBType, builder func() SQLExecutor)
- func RegisterCommonHook(hook SQLHook)
- func RegisterHook(hook SQLHook)
- func RegisterXAExecutor(dt types.DBType, builder func() SQLExecutor)
- type BaseExecutor
- func (e *BaseExecutor) ExecWithNamedValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error)
- func (e *BaseExecutor) ExecWithValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error)
- func (e *BaseExecutor) Interceptors(interceptors []SQLHook)
- type CallbackWithNamedValue
- type CallbackWithValue
- type MysqlXAConn
- func (c *MysqlXAConn) Commit(xid string, onePhase bool) error
- func (c *MysqlXAConn) End(xid string, flags int) error
- func (c *MysqlXAConn) Forget(xid string) error
- func (c *MysqlXAConn) GetTransactionTimeout() time.Duration
- func (c *MysqlXAConn) IsSameRM(xares XAResource) bool
- func (c *MysqlXAConn) Recover(flag int) (xids []string, err error)
- func (c *MysqlXAConn) Rollback(xid string) error
- func (c *MysqlXAConn) SetTransactionTimeout(duration time.Duration) bool
- func (c *MysqlXAConn) Start(xid string, flags int) error
- func (c *MysqlXAConn) XAPrepare(xid string) error
- type SQLExecutor
- type SQLHook
- type SelectForUpdateExecutor
- type XAResource
Constants ¶
const ( // TMENDICANT Ends a recovery scan. TMENDRSCAN = 0x00800000 /** * Disassociates the caller and marks the transaction branch * rollback-only. */ TMFAIL = 0x20000000 /** * Caller is joining existing transaction branch. */ TMJOIN = 0x00200000 /** * Use TMNOFLAGS to indicate no flags value is selected. */ TMNOFLAGS = 0x00000000 /** * Caller is using one-phase optimization. */ TMONEPHASE = 0x40000000 /** * Caller is resuming association with a suspended * transaction branch. */ TMRESUME = 0x08000000 /** * Starts a recovery scan. */ TMSTARTRSCAN = 0x01000000 /** * Disassociates caller from a transaction branch. */ TMSUCCESS = 0x04000000 /** * Caller is suspending (not ending) its association with * a transaction branch. */ TMSUSPEND = 0x02000000 /** * The transaction branch has been read-only and has been committed. */ XA_RDONLY = 0x00000003 /** * The transaction work has been prepared normally. */ XA_OK = 0 )
Variables ¶
This section is empty.
Functions ¶
func CleanCommonHook ¶
func CleanCommonHook()
func RegisterATExecutor ¶
func RegisterATExecutor(dt types.DBType, builder func() SQLExecutor)
RegisterATExecutor AT executor
func RegisterCommonHook ¶
func RegisterCommonHook(hook SQLHook)
RegisterCommonHook not goroutine safe
func RegisterXAExecutor ¶
func RegisterXAExecutor(dt types.DBType, builder func() SQLExecutor)
RegisterXAExecutor XA executor
Types ¶
type BaseExecutor ¶
type BaseExecutor struct {
// contains filtered or unexported fields
}
func (*BaseExecutor) ExecWithNamedValue ¶
func (e *BaseExecutor) ExecWithNamedValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error)
ExecWithNamedValue
func (*BaseExecutor) ExecWithValue ¶
func (e *BaseExecutor) ExecWithValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error)
ExecWithValue
func (*BaseExecutor) Interceptors ¶
func (e *BaseExecutor) Interceptors(interceptors []SQLHook)
Interceptors
type CallbackWithNamedValue ¶
type CallbackWithNamedValue func(ctx context.Context, query string, args []driver.NamedValue) (types.ExecResult, error)
type CallbackWithValue ¶
type MysqlXAConn ¶
func (*MysqlXAConn) Forget ¶
func (c *MysqlXAConn) Forget(xid string) error
func (*MysqlXAConn) GetTransactionTimeout ¶
func (c *MysqlXAConn) GetTransactionTimeout() time.Duration
func (*MysqlXAConn) IsSameRM ¶
func (c *MysqlXAConn) IsSameRM(xares XAResource) bool
IsSameRM is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.
func (*MysqlXAConn) Recover ¶
func (c *MysqlXAConn) Recover(flag int) (xids []string, err error)
Recover Obtains a list of prepared transaction branches from a resource manager. The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.
func (*MysqlXAConn) Rollback ¶
func (c *MysqlXAConn) Rollback(xid string) error
func (*MysqlXAConn) SetTransactionTimeout ¶
func (c *MysqlXAConn) SetTransactionTimeout(duration time.Duration) bool
func (*MysqlXAConn) XAPrepare ¶
func (c *MysqlXAConn) XAPrepare(xid string) error
type SQLExecutor ¶
type SQLExecutor interface { Interceptors(interceptors []SQLHook) ExecWithNamedValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error) ExecWithValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error) }
func BuildExecutor ¶
func BuildExecutor(dbType types.DBType, transactionMode types.TransactionMode, query string) (SQLExecutor, error)
BuildExecutor use db type and transaction type to build an executor. the executor can add custom hook, and intercept the user's business sql to generate the undo log.
type SQLHook ¶
type SQLHook interface { Type() types.SQLType Before(ctx context.Context, execCtx *types.ExecContext) error After(ctx context.Context, execCtx *types.ExecContext) error }
SQLHook SQL execution front and back interceptor case 1. Used to intercept SQL to achieve the generation of front and rear mirrors case 2. Burning point to report case 3. SQL black and white list
type SelectForUpdateExecutor ¶
type SelectForUpdateExecutor struct {
builder.BasicUndoLogBuilder
}
func (SelectForUpdateExecutor) ExecWithNamedValue ¶
func (s SelectForUpdateExecutor) ExecWithNamedValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithNamedValue) (types.ExecResult, error)
func (SelectForUpdateExecutor) ExecWithValue ¶
func (s SelectForUpdateExecutor) ExecWithValue(ctx context.Context, execCtx *types.ExecContext, f CallbackWithValue) (types.ExecResult, error)
type XAResource ¶
type XAResource interface { Commit(xid string, onePhase bool) error End(xid string, flags int) error Forget(xid string) error GetTransactionTimeout() time.Duration IsSameRM(resource XAResource) bool XAPrepare(xid string) error Recover(flag int) ([]string, error) Rollback(xid string) error SetTransactionTimeout(duration time.Duration) bool Start(xid string, flags int) error }