reader

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 gtid.Set) error

StartSyncByGTID implements Reader.StartSyncByGTID.

func (*FileReader) StartSyncByPos

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

StartSyncByPos implements Reader.StartSyncByPos.

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 gtid.Set) 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 {
	// 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 gtid.Set) error

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

	// GetEvent gets the binlog event one by one, it will block if no event can be read.
	// You can pass a context (like Cancel or Timeout) to break the block.
	GetEvent(ctx context.Context) (*replication.BinlogEvent, 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 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 gtid.Set) 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