undo

package
v1.0.2-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterUndoLogBuilder

func RegisterUndoLogBuilder(executorType types.ExecutorType, fun func() UndoLogBuilder)

func RegisterUndoLogManager

func RegisterUndoLogManager(m UndoLogManager) error

Types

type BranchUndoLog

type BranchUndoLog struct {
	// Xid
	Xid string `json:"xid"`
	// BranchID
	BranchID uint64 `json:"branchId"`
	// Logs
	Logs []SQLUndoLog `json:"sqlUndoLogs"`
}

BranchUndoLog

func (*BranchUndoLog) Marshal

func (b *BranchUndoLog) Marshal() []byte

Marshal

func (*BranchUndoLog) Reverse

func (b *BranchUndoLog) Reverse()

type SQLUndoLog

type SQLUndoLog struct {
	SQLType     types.SQLType      `json:"sqlType"`
	TableName   string             `json:"tableName"`
	BeforeImage *types.RecordImage `json:"beforeImage"`
	AfterImage  *types.RecordImage `json:"afterImage"`
}

SQLUndoLog

func (SQLUndoLog) SetTableMeta

func (s SQLUndoLog) SetTableMeta(tableMeta types.TableMeta)

type UndoExecutor

type UndoExecutor interface {
	ExecuteOn(ctx context.Context, dbType types.DBType, conn *sql.Conn) error
}

type UndoExecutorHolder

type UndoExecutorHolder interface {
	// GetInsertExecutor get the specific Insert UndoExecutor by sqlUndoLog
	GetInsertExecutor(sqlUndoLog SQLUndoLog) UndoExecutor

	// GetUpdateExecutor get the specific Update UndoExecutor by sqlUndoLog
	GetUpdateExecutor(sqlUndoLog SQLUndoLog) UndoExecutor

	// GetDeleteExecutor get the specific Delete UndoExecutor by sqlUndoLog
	GetDeleteExecutor(sqlUndoLog SQLUndoLog) UndoExecutor
}

type UndoLogBuilder

type UndoLogBuilder interface {
	BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error)
	AfterImage(ctx context.Context, execCtx *types.ExecContext, beforImages []*types.RecordImage) ([]*types.RecordImage, error)
	GetExecutorType() types.ExecutorType
}

func GetUndologBuilder

func GetUndologBuilder(sqlType types.ExecutorType) UndoLogBuilder

type UndoLogManager

type UndoLogManager interface {
	Init()
	// DeleteUndoLog
	DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error
	// BatchDeleteUndoLog
	BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error
	//FlushUndoLog
	FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error
	// RunUndo
	RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error
	// DBType
	DBType() types.DBType
	// HasUndoLogTable
	HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error)
}

UndoLogManager

func GetUndoLogManager

func GetUndoLogManager(d types.DBType) (UndoLogManager, error)

GetUndoLogManager

type UndoLogParser

type UndoLogParser interface {
	// GetName
	GetName() string
	// GetDefaultContent
	GetDefaultContent() []byte
	// Encode
	Encode(l BranchUndoLog) []byte
	// Decode
	Decode(b []byte) BranchUndoLog
}

UndoLogParser

type UndoLogStatue

type UndoLogStatue int8
const (
	UndoLogStatueNormnal        UndoLogStatue = 0
	UndoLogStatueGlobalFinished UndoLogStatue = 1
)

type UndologRecord

type UndologRecord struct {
	BranchID     uint64        `json:"branchId"`
	XID          string        `json:"xid"`
	Context      []byte        `json:"context"`
	RollbackInfo []byte        `json:"rollbackInfo"`
	LogStatus    UndoLogStatue `json:"logStatus"`
	LogCreated   []byte        `json:"logCreated"`
	LogModified  []byte        `json:"logModified"`
}

func (*UndologRecord) CanUndo

func (u *UndologRecord) CanUndo() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL