myslave

package
v0.0.0-...-c6e60ff Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2017 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package myslave simulates a mysql slave and listens for master to push the binlog stream.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRowFormat = errors.New("binlog must be ROW format")
)

Functions

func ParseDSN

func ParseDSN(dsn string) (zone, host string, port uint16, username, passwd string, dbs []string, err error)

ParseDSN parse mysql DSN(data source name). The DSN is in the form of mysql:zone://user:pass@host:port/db1,db2,...,dbn The zone is used for zk checkpoint.

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 New

func New(name, dsn string, cluster string) *MySlave

New creates a MySlave instance.

func (*MySlave) AssertValidRowFormat

func (m *MySlave) AssertValidRowFormat() error

AssertValidRowFormat asserts the mysql master binlog format is ROW.

func (*MySlave) BinlogByPos

func (m *MySlave) BinlogByPos(file string, pos int) (*mysql.Result, error)

BinlogByPos fetches a single binlog event by position.

func (*MySlave) BinlogRowImage

func (m *MySlave) BinlogRowImage() (string, error)

BinlogRowImage checks MySQL binlog row image, must be in FULL, MINIMAL, NOBLOB.

func (*MySlave) CommitPosition

func (m *MySlave) CommitPosition(file string, offset uint32) error

CommitPosition persists the binlog position to checkpointer.

func (*MySlave) DSN

func (m *MySlave) DSN() string

DSN returns the data source name of the mysql connection.

func (*MySlave) Errors

func (m *MySlave) Errors() <-chan error

Errors returns the iterator of unexpected errors.

func (*MySlave) Events

func (m *MySlave) Events() <-chan *model.RowsEvent

Events returns the iterator of mysql binlog rows event.

func (*MySlave) LoadConfig

func (m *MySlave) LoadConfig(config *conf.Conf) *MySlave

LoadConfig initialize internal state according to the config section.

func (*MySlave) MarkAsProcessed

func (m *MySlave) MarkAsProcessed(r *model.RowsEvent) error

MarkAsProcessed notifies the checkpoint that a certain binlog event has been successfully processed and should be committed.

func (*MySlave) MasterBinlogs

func (m *MySlave) MasterBinlogs() ([]string, error)

MasterBinlogs returns all binlog files on master.

func (*MySlave) MasterPosition

func (m *MySlave) MasterPosition() (*mysql.Position, error)

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.

func (*MySlave) TableColumns

func (m *MySlave) TableColumns(db, table string) ([]string, error)

TableColumns returns column names of a table in mysql.

Jump to

Keyboard shortcuts

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