Documentation
¶
Index ¶
- Variables
- func CollectAllBinlogFiles(dir string) ([]string, error)
- func CollectBinlogFilesCmp(dir, baseFile string, cmp FileCmp) ([]string, error)
- func ExtractPos(pos mysql.Position, uuids []string) (uuidWithSuffix string, uuidSuffix string, realPos mysql.Position, err error)
- func GetBinlogFileIndex(filename string) (float64, error)
- func RealMySQLPos(pos mysql.Position) (mysql.Position, error)
- type BinlogReader
- type BinlogReaderConfig
- type FileCmp
- type LocalStreamer
- type ReaderHub
- type RelayLogInfo
- type Streamer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidBinlogFilename means error about invalid binlog file name. ErrInvalidBinlogFilename = errors.New("invalid binlog file name") // ErrEmptyRelayDir means error about empty relay dir. ErrEmptyRelayDir = errors.New("empty relay dir") )
var ( ErrReaderRunning = errors.New("binlog reader is already running") ErrBinlogFileNotSpecified = errors.New("binlog file must be specified") )
errors used by reader
var ( ErrNeedSyncAgain = errors.New("Last sync error or closed, try sync and get event again") ErrSyncClosed = errors.New("Sync was closed") )
errors used by streamer
Functions ¶
func CollectAllBinlogFiles ¶
CollectAllBinlogFiles collects all valid binlog files in dir
func CollectBinlogFilesCmp ¶
CollectBinlogFilesCmp collects valid binlog files with a compare condition
func ExtractPos ¶
func ExtractPos(pos mysql.Position, uuids []string) (uuidWithSuffix string, uuidSuffix string, realPos mysql.Position, err error)
ExtractPos extracts (uuidWithSuffix, uuidSuffix, originalPos) from input pos (originalPos or convertedPos)
func GetBinlogFileIndex ¶
GetBinlogFileIndex return a float64 value of index.
func RealMySQLPos ¶
RealMySQLPos parses relay position and returns a mysql position and whether error occurs if parsed successfully and `UUIDSuffix` exists, sets position Name to `originalPos.NamePrefix + baseSeqSeparator + originalPos.NameSuffix`. if parsed failed returns given position and the traced error.
Types ¶
type BinlogReader ¶
type BinlogReader struct {
// contains filtered or unexported fields
}
BinlogReader is a binlog reader.
func NewBinlogReader ¶
func NewBinlogReader(cfg *BinlogReaderConfig) *BinlogReader
NewBinlogReader creates a new BinlogReader
type BinlogReaderConfig ¶
BinlogReaderConfig is the configuration for BinlogReader
type LocalStreamer ¶
type LocalStreamer struct {
// contains filtered or unexported fields
}
LocalStreamer reads and parses binlog events from local binlog file.
func (*LocalStreamer) GetEvent ¶
func (s *LocalStreamer) GetEvent(ctx context.Context) (*replication.BinlogEvent, error)
GetEvent gets the binlog event one by one, it will block until parser occurs some errors. You can pass a context (like Cancel or Timeout) to break the block.
type ReaderHub ¶
type ReaderHub struct {
// contains filtered or unexported fields
}
ReaderHub holds information for all active Readers
func GetReaderHub ¶
func GetReaderHub() *ReaderHub
GetReaderHub gets singleton instance of ReaderHub
func (*ReaderHub) EarliestActiveRelayLog ¶
func (h *ReaderHub) EarliestActiveRelayLog() *RelayLogInfo
EarliestActiveRelayLog implements RelayOperator.EarliestActiveRelayLog
func (*ReaderHub) RemoveActiveRelayLog ¶
RemoveActiveRelayLog removes active relay log for taskName
func (*ReaderHub) UpdateActiveRelayLog ¶
UpdateActiveRelayLog updates active relay log for taskName
type RelayLogInfo ¶
RelayLogInfo represents information for relay log
func (*RelayLogInfo) Earlier ¶
func (info *RelayLogInfo) Earlier(other *RelayLogInfo) bool
Earlier checks whether this relay log file is earlier than the other
func (*RelayLogInfo) String ¶
func (info *RelayLogInfo) String() string
String implements Stringer.String
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.