types

package
v0.0.0-...-59d6468 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusTxInfoUnprocessed = 1
	StatusTxInfoProcessed   = 2
)

Variables

This section is empty.

Functions

func BatchInsertTxInfo

func BatchInsertTxInfo(txInfoArr []ChTxInfo) error

func InsertBinlogEvents

func InsertBinlogEvents(binlogEvents []ChBinlogEvent) error

func InsertTxInfo

func InsertTxInfo(txInfo ChTxInfo) error

Types

type Action

type Action int
const (
	EventActionInsert Action = iota
	EventActionUpdate
	EventActionDelete
)

func (Action) String

func (a Action) String() string

type AuditLog

type AuditLog struct {
	Time         time.Time `ch:"time"`
	Context      string    `ch:"context"`
	GTID         string    `ch:"gtid"`
	BinlogEvents []ChBinlogEvent
}

func NewAuditLog

func NewAuditLog(txInfo ChTxInfo, events []ChBinlogEvent) *AuditLog

type BinlogEvent

type BinlogEvent struct {
	Db     string       `json:"db"`
	Table  string       `json:"table"`
	Action Action       `json:"action"`
	GTID   string       `json:"gtid"`
	Time   int64        `json:"time"`
	Data   sql.RawBytes `json:"data"`
}

func NewBinlogEvent

func NewBinlogEvent(event *river.EventData) (*BinlogEvent, error)

func (*BinlogEvent) ChEvent

func (e *BinlogEvent) ChEvent() ChBinlogEvent

func (*BinlogEvent) Marshal

func (e *BinlogEvent) Marshal() ([]byte, error)

type ChBinlogEvent

type ChBinlogEvent struct {
	Db     string `ch:"db"`
	Table  string `ch:"table"`
	Action int32  `ch:"action"`
	GTID   string `ch:"gtid"`
	Data   string `ch:"data"`
}

func ListBinlogEvent

func ListBinlogEvent(gtid string) ([]ChBinlogEvent, error)

func ListBinlogEvents

func ListBinlogEvents(gtidList []string) ([]ChBinlogEvent, error)

type ChTxInfo

type ChTxInfo struct {
	Time    time.Time `json:"time" ch:"time"`
	Context string    `json:"context" ch:"context"`
	GTID    string    `json:"gtid" ch:"gtid"`
	Status  uint8     `json:"-" ch:"-"`
}

func ListUnprocessedTxInfo

func ListUnprocessedTxInfo() ([]ChTxInfo, error)

type FormatData

type FormatData struct {
	Before map[string]interface{} `json:"before"` // 变更前数据, insert 类型的 before 为空
	After  map[string]interface{} `json:"after"`  // 变更后数据, delete 类型的 after 为空
}

type TxInfo

type TxInfo struct {
	Time    int64  `db:"time" json:"time"`
	Context string `db:"context" json:"context"`
	GTID    string `db:"gtid" json:"gtid"`
}

func NewTxInfo

func NewTxInfo(ctx, Gtid string) *TxInfo

func (*TxInfo) ChTxInfo

func (t *TxInfo) ChTxInfo(status uint8) ChTxInfo

func (*TxInfo) Marshal

func (t *TxInfo) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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