Documentation ¶
Overview ¶
Package myslave simulates a mysql slave and listens for master to push the binlog stream.
Index ¶
- Variables
- func ParseDSN(dsn string) (zone, host string, port uint16, username, passwd string, dbs []string, ...)
- type MySlave
- func (m *MySlave) AssertValidRowFormat() error
- func (m *MySlave) BinlogByPos(file string, pos int) (*mysql.Result, error)
- func (m *MySlave) BinlogRowImage() (string, error)
- func (m *MySlave) CommitPosition(file string, offset uint32) error
- func (m *MySlave) DSN() string
- func (m *MySlave) Errors() <-chan error
- func (m *MySlave) Events() <-chan *model.RowsEvent
- func (m *MySlave) LoadConfig(config *conf.Conf) *MySlave
- func (m *MySlave) MarkAsProcessed(r *model.RowsEvent) error
- func (m *MySlave) MasterBinlogs() ([]string, error)
- func (m *MySlave) MasterPosition() (*mysql.Position, error)
- func (m *MySlave) StartReplication(ready chan struct{})
- func (m *MySlave) StopReplication()
- func (m *MySlave) TableColumns(db, table string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidRowFormat = errors.New("binlog must be ROW format")
)
Functions ¶
Types ¶
type MySlave ¶
type MySlave struct { Predicate func(schema, table string) bool GTID bool // global tx id // contains filtered or unexported fields }
MySlave is a mimic mysql slave that replicates binlog from mysql master using IO thread.
func (*MySlave) AssertValidRowFormat ¶
AssertValidRowFormat asserts the mysql master binlog format is ROW.
func (*MySlave) BinlogByPos ¶
BinlogByPos fetches a single binlog event by position.
func (*MySlave) BinlogRowImage ¶
BinlogRowImage checks MySQL binlog row image, must be in FULL, MINIMAL, NOBLOB.
func (*MySlave) CommitPosition ¶
CommitPosition persists the binlog position to checkpointer.
func (*MySlave) LoadConfig ¶
LoadConfig initialize internal state according to the config section.
func (*MySlave) MarkAsProcessed ¶
MarkAsProcessed notifies the checkpoint that a certain binlog event has been successfully processed and should be committed.
func (*MySlave) MasterBinlogs ¶
MasterBinlogs returns all binlog files on master.
func (*MySlave) MasterPosition ¶
MasterPosition returns the latest mysql master binlog position info.
func (*MySlave) StartReplication ¶
func (m *MySlave) StartReplication(ready chan struct{})
StartReplication start the mysql binlog replication. TODO graceful shutdown TODO GTID
func (*MySlave) StopReplication ¶
func (m *MySlave) StopReplication()
StopReplication stops the slave and do necessary cleanups.