core

package
v0.0.0-...-677aa34 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACTION_UPDATE = "update"
	ACTION_INSERT = "insert"
	ACTION_DELETE = "delete"
)

The action name for sync.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity interface {
	SavePos() bool       // 实体ACK后是否需要保存位置
	Pos() mysql.Position // 获取位置信息
	String() string
}

Entity 事件实体 实体会直接存储在EventStore中 不同类型的Event实体,则处理不同 RowEvent实体不需要保存位置 XIDEvent,RotateEvent需要保存位置 保存位置信息时机为,Canald ACK后,倒叙拿到实体列表的最近的一个可保存的实体,获取位置信息缓存并落地 落地的策略根据配置可进行文件和Etcd落地

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message binlog消息

func NewMessage

func NewMessage(entris []Entity, bid int64) *Message

NewMessage new message

func (*Message) BatchID

func (message *Message) BatchID() int64

BatchID batchID

func (*Message) Events

func (message *Message) Events() []Entity

Events all message events

func (*Message) Len

func (message *Message) Len() int

Len length

func (*Message) Reset

func (message *Message) Reset(batid int64, entitys []Entity)

Reset reset

type Record

type Record struct {
	// 区分多个用户空间
	Namespace string                   `json:"namespace"` // 命名空间
	Action    string                   `json:"action"`
	Schema    string                   `json:"schema"`
	Name      string                   `json:"name"`
	PkNames   []string                 `json:"pk_names"`
	Columns   []map[string]interface{} `json:"columns"` // 字段 和 对应的值
}

Record 数据库记录变更结构

func (Record) ColumnsBytes

func (record Record) ColumnsBytes() ([]byte, error)

ColumnsBytes columns bytes

func (Record) Index

func (record Record) Index() string

Index index

func (Record) String

func (record Record) String() string

String string

func (Record) Type

func (record Record) Type() string

Type type

type RotateEvent

type RotateEvent struct {
	Save    bool
	LogPos  uint32
	LogName string
}

RotateEvent binglog文件轮转

func (*RotateEvent) Pos

func (r *RotateEvent) Pos() mysql.Position

Pos 获取位置信息

func (*RotateEvent) SavePos

func (r *RotateEvent) SavePos() bool

SavePos 实体ACK后是否需要保存位置

func (*RotateEvent) String

func (r *RotateEvent) String() string

String string

type RowsEvent

type RowsEvent struct {
	LogName string // binlog 文件名称
	Save    bool   // 是否保存位点
	Table   *schema.Table
	Action  string
	// changed row list
	// binlog has three update event version, v0, v1 and v2.
	// for v1 and v2, the rows number must be even.
	// Two rows for one event, format is [before update row, after update row]
	// for update v0, only one row for a event, and we don't support this version.
	Rows [][]interface{}
	// Header can be used to inspect the event
	Header *replication.EventHeader
}

RowsEvent is the event for row replication.

func NewRowsEvent

func NewRowsEvent(table *schema.Table, action, logName string,
	rows [][]interface{}, header *replication.EventHeader) *RowsEvent

NewRowsEvent new rows event

func (*RowsEvent) Pos

func (r *RowsEvent) Pos() mysql.Position

Pos 获取位置信息

func (*RowsEvent) Records

func (r *RowsEvent) Records(namespace string) []Record

Record 解析一个Record

func (*RowsEvent) SavePos

func (r *RowsEvent) SavePos() bool

SavePos 实体ACK后是否需要保存位置

func (*RowsEvent) String

func (r *RowsEvent) String() string

String implements fmt.Stringer interface.

type XIDEvent

type XIDEvent struct {
	Save    bool
	LogPos  uint32
	LogName string
}

XIDEvent 事件结束

func (*XIDEvent) Pos

func (r *XIDEvent) Pos() mysql.Position

Pos 获取位置信息

func (*XIDEvent) SavePos

func (r *XIDEvent) SavePos() bool

SavePos 实体ACK后是否需要保存位置

func (*XIDEvent) String

func (r *XIDEvent) String() string

String string

Jump to

Keyboard shortcuts

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