proto

package
v0.0.0-...-2166858 Latest Latest
Warning

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

Go to latest
Published: May 28, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BL_UNRECOGNIZED = iota
	BL_BEGIN
	BL_COMMIT
	BL_ROLLBACK
	BL_DML
	BL_DDL
	BL_SET
)

Valid statement types in the binlogs.

Variables

View Source
var BL_CATEGORY_NAMES = map[int]string{
	BL_UNRECOGNIZED: "BL_UNRECOGNIZED",
	BL_BEGIN:        "BL_BEGIN",
	BL_COMMIT:       "BL_COMMIT",
	BL_ROLLBACK:     "BL_ROLLBACK",
	BL_DML:          "BL_DML",
	BL_DDL:          "BL_DDL",
	BL_SET:          "BL_SET",
}

Functions

This section is empty.

Types

type BinlogEvent

type BinlogEvent interface {
	// IsValid returns true if the underlying data buffer contains a valid event.
	// This should be called first on any BinlogEvent, and other methods should
	// only be called if this one returns true. This ensures you won't get panics
	// due to bounds checking on the byte array.
	IsValid() bool

	// IsFormatDescription returns true if this is a FORMAT_DESCRIPTION_EVENT.
	IsFormatDescription() bool
	// IsQuery returns true if this is a QUERY_EVENT, which encompasses all SQL
	// statements.
	IsQuery() bool
	// IsXID returns true if this is an XID_EVENT, which is an alternate form of
	// COMMIT.
	IsXID() bool
	// IsGTID returns true if this is a GTID_EVENT.
	IsGTID() bool
	// IsRotate returns true if this is a ROTATE_EVENT.
	IsRotate() bool
	// IsIntVar returns true if this is an INTVAR_EVENT.
	IsIntVar() bool
	// IsRand returns true if this is a RAND_EVENT.
	IsRand() bool
	// HasGTID returns true if this event contains a GTID. That could either be
	// because it's a GTID_EVENT (MariaDB, MySQL 5.6), or because it is some
	// arbitrary event type that has a GTID in the header (Google MySQL).
	HasGTID(BinlogFormat) bool

	// Timestamp returns the timestamp from the event header.
	Timestamp() uint32

	// Format returns a BinlogFormat struct based on the event data.
	// This is only valid if IsFormatDescription() returns true.
	Format() (BinlogFormat, error)
	// GTID returns the GTID from the event.
	// This is only valid if HasGTID() returns true.
	GTID(BinlogFormat) (myproto.GTID, error)
	// IsBeginGTID returns true if this is a GTID_EVENT that also serves as a
	// BEGIN statement. Otherwise, the GTID_EVENT is just providing the GTID for
	// the following QUERY_EVENT.
	// This is only valid if IsGTID() returns true.
	IsBeginGTID(BinlogFormat) bool
	// Query returns a Query struct representing data from a QUERY_EVENT.
	// This is only valid if IsQuery() returns true.
	Query(BinlogFormat) (Query, error)
	// IntVar returns the name and value of the variable for an INTVAR_EVENT.
	// This is only valid if IsIntVar() returns true.
	IntVar(BinlogFormat) (string, uint64, error)
	// Rand returns the two seed values for a RAND_EVENT.
	// This is only valid if IsRand() returns true.
	Rand(BinlogFormat) (uint64, uint64, error)

	// StripChecksum returns the checksum and a modified event with the checksum
	// stripped off, if any. If there is no checksum, it returns the same event
	// and a nil checksum.
	StripChecksum(BinlogFormat) (ev BinlogEvent, checksum []byte)
}

BinlogEvent represents a single event from a raw MySQL binlog dump stream. The implementation is provided by each supported flavor in go/vt/mysqlctl.

BinlogStreamer receives these events through a mysqlctl.SlaveConnection and processes them, grouping statements into BinlogTransactions as appropriate.

Methods that only access header fields can't fail as long as IsValid() returns true, so they have a single return value. Methods that might fail even when IsValid() is true return an error value.

Methods that require information from the initial FORMAT_DESCRIPTION_EVENT will have a BinlogFormat parameter.

type BinlogFormat

type BinlogFormat struct {
	// FormatVersion is the version number of the binlog file format.
	FormatVersion uint16
	// ServerVersion is the name of the MySQL server version.
	ServerVersion string
	// HeaderLength is the size in bytes of event headers other than FORMAT_DESCRIPTION_EVENT.
	HeaderLength byte
	// ChecksumAlgorithm is the ID number of the binlog checksum algorithm.
	ChecksumAlgorithm byte
}

BinlogFormat contains relevant data from the FORMAT_DESCRIPTION_EVENT. This structure is passed to subsequent event types to let them know how to parse themselves.

func (BinlogFormat) IsZero

func (f BinlogFormat) IsZero() bool

IsZero returns true if the BinlogFormat has not been initialized.

type BinlogTransaction

type BinlogTransaction struct {
	Statements []Statement
	Timestamp  int64
	GTIDField  myproto.GTIDField
}

BinlogTransaction represents one transaction as read from the binlog. Timestamp is set if the first statement was something like 'SET TIMESTAMP=...'

func (*BinlogTransaction) MarshalBson

func (binlogTransaction *BinlogTransaction) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes BinlogTransaction.

func (*BinlogTransaction) UnmarshalBson

func (binlogTransaction *BinlogTransaction) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into BinlogTransaction.

type BlpPosition

type BlpPosition struct {
	Uid      uint32
	Position myproto.ReplicationPosition
}

BlpPosition describes a binlog player position to start from.

func (*BlpPosition) MarshalBson

func (blpPosition *BlpPosition) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes BlpPosition.

func (*BlpPosition) UnmarshalBson

func (blpPosition *BlpPosition) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into BlpPosition.

type BlpPositionList

type BlpPositionList struct {
	Entries []BlpPosition
}

BlpPositionList is a list of BlpPosition, not sorted.

func (*BlpPositionList) FindBlpPositionById

func (bpl *BlpPositionList) FindBlpPositionById(id uint32) (*BlpPosition, error)

FindBlpPositionById returns the BlpPosition with the given id, or error

func (*BlpPositionList) MarshalBson

func (blpPositionList *BlpPositionList) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes BlpPositionList.

func (*BlpPositionList) UnmarshalBson

func (blpPositionList *BlpPositionList) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into BlpPositionList.

type KeyRangeRequest

type KeyRangeRequest struct {
	Position       myproto.ReplicationPosition
	KeyspaceIdType key.KeyspaceIdType
	KeyRange       key.KeyRange
	Charset        *mproto.Charset
}

KeyRangeRequest is used to make a request for StreamKeyRange.

type Query

type Query struct {
	Database string
	Charset  *mproto.Charset
	Sql      []byte
}

Query contains data from a QUERY_EVENT.

func (Query) String

func (q Query) String() string

String pretty-prints a Query.

type Statement

type Statement struct {
	Category int
	Charset  *mproto.Charset
	Sql      []byte
}

Statement represents one statement as read from the binlog.

func (*Statement) MarshalBson

func (statement *Statement) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes Statement.

func (Statement) String

func (s Statement) String() string

String pretty-prints a statement.

func (*Statement) UnmarshalBson

func (statement *Statement) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into Statement.

type StreamEvent

type StreamEvent struct {
	// Category can be "DML", "DDL", "ERR" or "POS"
	Category string

	// DML
	TableName  string
	PKColNames []string
	PKValues   [][]interface{}

	// DDL or ERR
	Sql string

	// Timestamp is set for DML, DDL or ERR
	Timestamp int64

	// POS
	GTIDField myproto.GTIDField
}

StreamEvent represents one event for the update stream.

func (*StreamEvent) MarshalBson

func (streamEvent *StreamEvent) MarshalBson(buf *bytes2.ChunkedWriter, key string)

MarshalBson bson-encodes StreamEvent.

func (*StreamEvent) UnmarshalBson

func (streamEvent *StreamEvent) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into StreamEvent.

type TablesRequest

type TablesRequest struct {
	Position myproto.ReplicationPosition
	Tables   []string
	Charset  *mproto.Charset
}

TablesRequest is used to make a request for StreamTables.

type UpdateStreamRequest

type UpdateStreamRequest struct {
	Position myproto.ReplicationPosition
}

UpdateStreamRequest is used to make a request for ServeUpdateStream.

Jump to

Keyboard shortcuts

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