binlog

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotDML    EventDML = "NoDML"
	InsertDML          = "Insert"
	UpdateDML          = "Update"
	DeleteDML          = "Delete"
)
View Source
const (
	InvalidState                      BinlogEntryState = "InvalidState"
	SearchForStartPosOrStatementState                  = "SearchForStartPosOrStatementState"
	ExpectEndLogPosState                               = "ExpectEndLogPosState"
	ExpectTokenState                                   = "ExpectTokenState"
	PositionalColumnAssignmentState                    = "PositionalColumnAssignmentState"
)

States of the state machine

Variables

This section is empty.

Functions

This section is empty.

Types

type BinlogCoordinates

type BinlogCoordinates struct {
	LogFile string
	LogPos  int64
	Type    BinlogType
}

BinlogCoordinates described binary log coordinates in the form of log file & log position.

func ParseBinlogCoordinates

func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)

ParseBinlogCoordinates will parse an InstanceKey from a string representation such as 127.0.0.1:3306

func (*BinlogCoordinates) DisplayString

func (this *BinlogCoordinates) DisplayString() string

DisplayString returns a user-friendly string representation of these coordinates

func (*BinlogCoordinates) Equals

func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool

Equals tests equality of this corrdinate and another one.

func (*BinlogCoordinates) FileNumber

func (this *BinlogCoordinates) FileNumber() (int, int)

FileNumber returns the numeric value of the file, and the length in characters representing the number in the filename. Example: FileNumber() of mysqld.log.000789 is (789, 6)

func (*BinlogCoordinates) FileNumberDistance

func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int

FileNumberDistance returns the numeric distance between this corrdinate's file number and the other's. Effectively it means "how many roatets/FLUSHes would make these coordinates's file reach the other's"

func (*BinlogCoordinates) FileSmallerThan

func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool

FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.

func (*BinlogCoordinates) IsEmpty

func (this *BinlogCoordinates) IsEmpty() bool

IsEmpty returns true if the log file is empty, unnamed

func (*BinlogCoordinates) NextFileCoordinates

func (this *BinlogCoordinates) NextFileCoordinates() (BinlogCoordinates, error)

NextFileCoordinates guesses the filename of the next binlog/relaylog

func (*BinlogCoordinates) PreviousFileCoordinates

func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)

PreviousFileCoordinates guesses the filename of the previous binlog/relaylog

func (*BinlogCoordinates) PreviousFileCoordinatesBy

func (this *BinlogCoordinates) PreviousFileCoordinatesBy(offset int) (BinlogCoordinates, error)

PreviousFileCoordinatesBy guesses the filename of the previous binlog/relaylog, by given offset (number of files back)

func (*BinlogCoordinates) SmallerThan

func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool

SmallerThan returns true if this coordinate is strictly smaller than the other.

func (*BinlogCoordinates) SmallerThanOrEquals

func (this *BinlogCoordinates) SmallerThanOrEquals(other *BinlogCoordinates) bool

SmallerThanOrEquals returns true if this coordinate is the same or equal to the other one. We do NOT compare the type so we can not use this.Equals()

func (BinlogCoordinates) String

func (this BinlogCoordinates) String() string

String returns a user-friendly string representation of these coordinates

type BinlogDMLEvent

type BinlogDMLEvent struct {
	DatabaseName      string
	TableName         string
	DML               EventDML
	WhereColumnValues *sql.ColumnValues
	NewColumnValues   *sql.ColumnValues
}

BinlogDMLEvent is a binary log rows (DML) event entry, with data

func NewBinlogDMLEvent

func NewBinlogDMLEvent(databaseName, tableName string, dml EventDML) *BinlogDMLEvent

func (*BinlogDMLEvent) String

func (this *BinlogDMLEvent) String() string

type BinlogEntry

type BinlogEntry struct {
	Coordinates mysql.BinlogCoordinates
	EndLogPos   uint64

	DmlEvent *BinlogDMLEvent
}

BinlogEntry describes an entry in the binary log

func NewBinlogEntry

func NewBinlogEntry(logFile string, logPos uint64) *BinlogEntry

NewBinlogEntry creates an empty, ready to go BinlogEntry object

func NewBinlogEntryAt

func NewBinlogEntryAt(coordinates mysql.BinlogCoordinates) *BinlogEntry

NewBinlogEntry creates an empty, ready to go BinlogEntry object

func (*BinlogEntry) Duplicate

func (this *BinlogEntry) Duplicate() *BinlogEntry

Duplicate creates and returns a new binlog entry, with some of the attributes pre-assigned

func (*BinlogEntry) String

func (this *BinlogEntry) String() string

Duplicate creates and returns a new binlog entry, with some of the attributes pre-assigned

type BinlogEntryState

type BinlogEntryState string

BinlogEntryState is a state in the binlog parser automaton / state machine

type BinlogReader

type BinlogReader interface {
	StreamEvents(canStopStreaming func() bool, entriesChannel chan<- *BinlogEntry) error
}

BinlogReader is a general interface whose implementations can choose their methods of reading a binary log file and parsing it into binlog entries

type BinlogType

type BinlogType int

BinlogType identifies the type of the log: relay or binary log

const (
	BinaryLog BinlogType = iota
	RelayLog
)

BinaryLog, RelayLog are binlog types

type EventDML

type EventDML string

func ToEventDML

func ToEventDML(description string) EventDML

type GoMySQLReader

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

func NewGoMySQLReader

func NewGoMySQLReader(connectionConfig *mysql.ConnectionConfig) (binlogReader *GoMySQLReader, err error)

func (*GoMySQLReader) ConnectBinlogStreamer

func (this *GoMySQLReader) ConnectBinlogStreamer(coordinates mysql.BinlogCoordinates) (err error)

ConnectBinlogStreamer

func (*GoMySQLReader) StreamEvents

func (this *GoMySQLReader) StreamEvents(canStopStreaming func() bool, entriesChannel chan<- *BinlogEntry) error

StreamEvents

type MySQLBinlogReader

type MySQLBinlogReader struct {
	Basedir           string
	Datadir           string
	MySQLBinlogBinary string
}

MySQLBinlogReader reads binary log entries by executing the `mysqlbinlog` process and textually parsing its output

func NewMySQLBinlogReader

func NewMySQLBinlogReader(basedir string, datadir string) (mySQLBinlogReader *MySQLBinlogReader)

NewMySQLBinlogReader creates a new reader that directly parses binlog files from the filesystem

func (*MySQLBinlogReader) ReadEntries

func (this *MySQLBinlogReader) ReadEntries(logFile string, startPos uint64, stopPos uint64) (entries [](*BinlogEntry), err error)

ReadEntries will read binlog entries from parsed text output of `mysqlbinlog` utility

Jump to

Keyboard shortcuts

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