reader

package
v0.0.0-...-6a53270 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGTIDsForPos

func GetGTIDsForPos(ctx context.Context, r Reader, endPos gmysql.Position) (gmysql.GTIDSet, error)

GetGTIDsForPos tries to get GTID sets for the specified binlog position (for the corresponding txn). NOTE: this method is very similar with `relay/writer/file_util.go/getTxnPosGTIDs`, unify them if needed later. NOTE: this method is not well tested directly, but more tests have already been done for `relay/writer/file_util.go/getTxnPosGTIDs`.

func GetGTIDsForPosFromStreamer

func GetGTIDsForPosFromStreamer(ctx context.Context, r Streamer, endPos gmysql.Position) (gmysql.GTIDSet, error)

GetGTIDsForPosFromStreamer tries to get GTID sets for the specified binlog position (for the corresponding txn) from a Streamer.

func GetPreviousGTIDFromGTIDSet

func GetPreviousGTIDFromGTIDSet(ctx context.Context, r Reader, gset gmysql.GTIDSet) (gmysql.GTIDSet, error)

GetPreviousGTIDFromGTIDSet tries to get previous GTID sets from Previous_GTID_EVENT GTID for the specified GITD Set. events should be [fake_rotate_event,format_description_event,previous_gtids_event/mariadb_gtid_list_event].

Types

type FileReader

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

FileReader is a binlog event reader which reads binlog events from a file.

func (*FileReader) Close

func (r *FileReader) Close() error

Close implements Reader.Close.

func (*FileReader) GetEvent

func (r *FileReader) GetEvent(ctx context.Context) (*replication.BinlogEvent, error)

GetEvent implements Reader.GetEvent.

func (*FileReader) StartSyncByGTID

func (r *FileReader) StartSyncByGTID(gSet gmysql.GTIDSet) error

StartSyncByGTID implements Reader.StartSyncByGTID.

func (*FileReader) StartSyncByPos

func (r *FileReader) StartSyncByPos(pos gmysql.Position) error

StartSyncByPos implements Reader.StartSyncByPos. TODO: support heartbeat event.

func (*FileReader) Status

func (r *FileReader) Status() interface{}

Status implements Reader.Status.

type FileReaderConfig

type FileReaderConfig struct {
	EnableRawMode bool
	Timezone      *time.Location
	ChBufferSize  int // event channel's buffer size
	EchBufferSize int // error channel's buffer size
}

FileReaderConfig is the configuration used by a FileReader.

type FileReaderStatus

type FileReaderStatus struct {
	Stage      string `json:"stage"`
	ReadOffset uint32 `json:"read-offset"` // read event's offset in the file
	SendOffset uint32 `json:"send-offset"` // sent event's offset in the file
}

FileReaderStatus represents the status of a FileReader.

func (*FileReaderStatus) String

func (s *FileReaderStatus) String() string

String implements Stringer.String.

type MockReader

type MockReader struct {

	// returned error for methods
	ErrStartByPos  error
	ErrStartByGTID error
	ErrClose       error
	// contains filtered or unexported fields
}

MockReader is a binlog event reader which read binlog events from an input channel.

func (*MockReader) Close

func (r *MockReader) Close() error

Close implements Reader.Close.

func (*MockReader) GetEvent

func (r *MockReader) GetEvent(ctx context.Context) (*replication.BinlogEvent, error)

GetEvent implements Reader.GetEvent.

func (*MockReader) PushError

func (r *MockReader) PushError(ctx context.Context, err error) error

PushError pushes an error into the reader.

func (*MockReader) PushEvent

func (r *MockReader) PushEvent(ctx context.Context, ev *replication.BinlogEvent) error

PushEvent pushes an event into the reader.

func (*MockReader) StartSyncByGTID

func (r *MockReader) StartSyncByGTID(gSet gmysql.GTIDSet) error

StartSyncByGTID implements Reader.StartSyncByGTID.

func (*MockReader) StartSyncByPos

func (r *MockReader) StartSyncByPos(pos gmysql.Position) error

StartSyncByPos implements Reader.StartSyncByPos.

func (*MockReader) Status

func (r *MockReader) Status() interface{}

Status implements Reader.Status.

type Reader

type Reader interface {
	Streamer

	// StartSyncByPos prepares the reader for reading binlog from the specified position.
	StartSyncByPos(pos gmysql.Position) error

	// StartSyncByGTID prepares the reader for reading binlog from the specified GTID set.
	StartSyncByGTID(gSet gmysql.GTIDSet) error

	// Close closes the reader and release the resource.
	// Close will be blocked if `GetEvent` has not returned.
	Close() error

	// Status returns the status of the reader.
	Status() interface{}
}

Reader is a binlog event reader, it may read binlog events from a TCP stream, binlog files or any other in-memory buffer. One reader should read binlog events either through position mode or GTID mode.

func NewFileReader

func NewFileReader(cfg *FileReaderConfig) Reader

NewFileReader creates a FileReader instance.

func NewMockReader

func NewMockReader() Reader

NewMockReader creates a MockReader instance.

func NewTCPReader

func NewTCPReader(syncerCfg replication.BinlogSyncerConfig) Reader

NewTCPReader creates a TCPReader instance.

type Streamer

type Streamer interface {
	// GetEvent returns binlog event
	GetEvent(ctx context.Context) (*replication.BinlogEvent, error)
}

Streamer provides the ability to get binlog event from remote server or local file.

type TCPReader

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

TCPReader is a binlog event reader which read binlog events from a TCP stream.

func (*TCPReader) Close

func (r *TCPReader) Close() error

Close implements Reader.Close.

func (*TCPReader) GetEvent

func (r *TCPReader) GetEvent(ctx context.Context) (*replication.BinlogEvent, error)

GetEvent implements Reader.GetEvent.

func (*TCPReader) StartSyncByGTID

func (r *TCPReader) StartSyncByGTID(gSet gmysql.GTIDSet) error

StartSyncByGTID implements Reader.StartSyncByGTID.

func (*TCPReader) StartSyncByPos

func (r *TCPReader) StartSyncByPos(pos gmysql.Position) error

StartSyncByPos implements Reader.StartSyncByPos.

func (*TCPReader) Status

func (r *TCPReader) Status() interface{}

Status implements Reader.Status.

type TCPReaderStatus

type TCPReaderStatus struct {
	Stage  string `json:"stage"`
	ConnID uint32 `json:"connection"`
}

TCPReaderStatus represents the status of a TCPReader.

func (*TCPReaderStatus) String

func (s *TCPReaderStatus) String() string

String implements Stringer.String.

Jump to

Keyboard shortcuts

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